Questions from Beginners MQL5 MT5 MetaTrader 5 - page 571

 
Artyom Trishkin:

There was a question like this once before:


Alexey Viktorov:

lot = (absolute_value(profit_order) + desired profit) / (size_standard_contract * TR * point)

Thank you, Artyom Trishkin.

Thank you, Alexey Viktorov.

 
Karputov Vladimir:
Do you understand the very definition of 'asynchronous operation'? If you do, there should be no questions asked.
I understand it very well! That's why I asked. I don't intend to wrestle piss competence with you.
 

Colleagues, helpa novice programmer.

Tried to make up a code of custom function, so that when I set time in settings in usual format "13:45" for three time-sessions, my function will return true or false. The idea was to insert the function into Expert first. It would check the value and, if true, we could trade and move on.

Everything seemed to be going well, all returned parameters were checked with Alert, so that everything was clear at all stages, but in the end I realized that I must have declared it incorrectly in Start function, because it generated error "wrong parameters count".

The code is long, I'll give you the highlights:

--------------------------------

void OnTick()

{

bool TradingAllowed = false;

TradeTimeAllowed (TradingAllowed);

if (TradingAllowed = true) { Alert ("Buy 1 lot");}

else { Alert ("Trading is not allowed"); }

}

//+------------------------------------------------------------------+

bool TradeTimeAllowed (string TS1, string TE1, string TS2, string TE2, string TS3, string TE3) //there is a function itself. I have tested it by inserting into OnTick via Alert. It outputs true or false.

{ ....................}

---------------------

And second problem is in function itself at the end.

Now it is incorrectly placed there:

if (Trade_Session_1 = true) TradeTime_Ok = true;

if (Trade_Session_2 = true) TradeTime_Ok = true;

if (Trade_Session_3 = true) TradeTime_Ok = true;

return(TradeTime_Ok);

// i.e. the problem is "who's last, who's next". If the first period is true or the second one is true, and the third one is false, it will remember false. But according to my idea, if at least one of them is true, the final value is still true.

I tried to put it this way:

if (Trade_Session_1 = true || Trade_Session_2 = true || Trade_Session_3 = true) TradeTime_Ok = true; // but it writes error like this. I do not know what he does not like.

Good advice, please.


 

The first problem was solved with the help of the kind people in the neighbouring thread. The function is called correctly and outputs the required value.

The second problem remains:

And the second problem is in the function itself at the end.

It is incorrectly written there now:

if (Trade_Session_1 = true) TradeTime_Ok = true;

if (Trade_Session_2 = true) TradeTime_Ok = true;

if (Trade_Session_3 = true) TradeTime_Ok = true;

return(TradeTime_Ok);

// i.e. the problem is "who's last, who's next". If the first period is true or the second one is true, and the third one is false, it will remember false. But according to my idea, if at least one of them is true, the final value is still true.

I tried to put it this way:

if (Trade_Session_1 = true || Trade_Session_2 = true || Trade_Session_3 = true) TradeTime_Ok = true; // but it writes error like this. I do not know what he does not like.

Good advice, please.

 

Transferred from

Andrey Koldorkin:

Colleagues, help for a novice programmer.

Tried to cobble together some code for a custom function to return true or false for three time-sessions, when I set time in settings in familiar format "13:45". The idea was to insert the function into Expert first. It would check the value and, if true, we could trade and move on.

Everything seemed to be going well, all returned parameters were checked with Alert, so that everything was clear at all stages, but in the end I realized that I must have declared it incorrectly in Start function, because it generated error "wrong parameters count".

The code is long, I'll give you the highlights:

--------------------------------

void OnTick()

{

bool TradingAllowed = false;

TradeTimeAllowed (TradingAllowed);

if (TradingAllowed = true) { Alert ("Buy 1 lot");}

else { Alert ("Trading is not allowed"); }

}

//+------------------------------------------------------------------+

bool TradeTimeAllowed (string TS1, string TE1, string TS2, string TE2, string TS3, string TE3) //there is a function. I checked it by inserting into OnTick via Alert. Produces true or false.

{ ....................}

---------------------

And second problem is in function itself at the end.

Now it is incorrectly placed there:

if (Trade_Session_1 = true) TradeTime_Ok = true;

if (Trade_Session_2 = true) TradeTime_Ok = true;

if (Trade_Session_3 = true) TradeTime_Ok = true;

return(TradeTime_Ok);

// i.e. the problem is "who's last, who's next". If the first period is true or the second one is true, and the third one is false, it will remember false. But according to my idea, if at least one of them is true, the final value is still true.

I tried to put it this way:

if (Trade_Session_1 = true || Trade_Session_2 = true || Trade_Session_3 = true) TradeTime_Ok = true; // but it writes error like this. I do not know what he does not like.

Please, help me.

 

Transferred

<br / translate="no"> Andrey Koldorkin:


Sergei Vladimirov:

1) The function requires 6 string parameters and you call it with one boolean parameter. 2) The equal sign is "==", not "=".

 
Yeah. All fixed. The mistakes are gone. Thank you. (chuckles)
 

Transferred from

LeonidB:

Help solve a problem!

News category settings are not being saved. Reset the settings after restarting the terminal. Reinstalling doesn't help, running as administrator doesn't help. Windpws 10. I've found all the files responsible for configuration, dates of changes always coincide with the date of terminal shutdown, i.e. files are overwritten. As far as I understand, the following files are responsible for configuration: terminal.ini, settings.ini, hotkeys.ini, common.ini (located in config folder), news.dat (located in news folder).

Also, the following setting is not saved: Show - Last Price Line. This point is not critical as opposed to the news settings, but I think they are links in the same chain.


 

Good afternoon all, posted on fours, hope to hear back soon.... Guys, please look what's wrong. It seems to be the code of indicator in two lines, but it doesn't want to work in real time :-(

Here is a link to a post with three pictures....

https://forum.mql4.com/ru/56236/page1041

Thanks!!!!

Любой вопрос новичка, чтоб не захламлять форум. Профи, не проходите мимо. Без вас никуда - 6. (faq) - MQL4 форум - Страница 1041
Любой вопрос новичка, чтоб не захламлять форум. Профи, не проходите мимо. Без вас никуда - 6. (faq) - MQL4 форум - Страница 1041
  • www.mql5.com
Любой вопрос новичка, чтоб не захламлять форум. Профи, не проходите мимо. Без вас никуда - 6. (faq) - MQL4 форум - Страница 1041
 
Hi, I am looking for an EA for my trading account. I have written an EA in MT5 that I have wanted to use to automatically search for the necessary patterns and open positions manually. I.e. there are no trading functions in the EA. My problem is that I cannot install this EA on a chart. There are no indicator calls in the EA. All indicators are written in program. I compiled it and ran it in the strategy tester. There were no problems. I have just put the EA on the chart and allowed it to trade on the screen, in the settings and in the EA window that pops up. Instead of the smiley face on the chart, the Expert Advisor's icon appears on the price chart and a green circle with a white triangle inside it. I have tried this procedure several times and still get the same results. I changed periods on the price chart, the message from OnDeinit() appears on the monitor, i.e. one candle is processed in the program and work stops.

I took a look at the logbook:

- One of the attempts to install an EA resulted in a Profile change message;

- In all other attempts the EA is loaded without any problems.

I used to work with Profiles: I increased the number of Profiles, set different charts on each Profile. If there was something wrong there, unfortunately, I don't know it. I don't know what must be broken in order for the program to give a message about profile change. Although it is possible that the failure is due to some other reason. It is not clear to me.

For the sake of testing, I have created a new EA (template) today and did not write anything in the OnInit(), OnDeinit(const int reason), OnTick() functions and tried to put this EA on the chart and allow trading.

I got the same situation as before.

Please help me to understand this situation. Thank you !!!!!!

Reason: