Questions from Beginners MQL5 MT5 MetaTrader 5 - page 571
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
Do you understand the very definition of 'asynchronous operation'? If you do, there should be no questions asked.
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
1) The function requires 6 string parameters and you call it with one boolean parameter. 2) The equal sign is "==", not "=".
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!!!!
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 !!!!!!