If price closes below the moving average and Momentum is below the average, open a sell trade. On a buy trade, it is the other way round.
It turns out that if the condition is not fulfilled, then no action is needed. If so, then in the last line of the function write return(false) and see if it will satisfy your tactic step by step.
Yedelkin: So, if the condition is not met, you don't need to do anything? If so, then in the last line of the function write return(false) and see if it will satisfy your tactic step by step.
Try putting false on the last line and see if this approach is consistent with the tactic you have chosen. I.e., "scroll" the Expert Advisor's work with this change in mind.
Interesting: I was talking about timeOntrade apparently.
In timontrade just false at the end will not give the desired result, but in my variant it really opens deals by the clock, tested. My version of code with clock in this form I got somewhere here on forum, it works after screwing it in. Only the minutes I managed to screw in via timontrade two. I'm sure the full code should be a third shorter at least.
alph: In timontrade, it's exactly false at the end that won't produce the desired result...
Well look at your code yourself. The condition if(timeOntrade.hour==4 || timeOntrade.hour==15 || timeOntrade.hour==16) is useless in its current form. Because no matter what result it produces, your bool timeOntrade() function will always return true.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
If price closes below the moving average and Momentum is below the average, open a sell trade. On a buy trade, it is the other way round.
So, if the condition is not met, you don't need to do anything? If so, then in the last line of the function write return(false) and see if it will satisfy your tactic step by step.
Is it in void OnTick() ?
It was about timeOntrade apparently.
But I'm personally confused by the non-returnable result, which can be converted to the desired form sooner or later.
What confuses me is this
Is this in void OnTick() ?
Right here:
Try putting false on the last line and see if this approach is consistent with the tactic you have chosen. I.e., "scroll" the Expert Advisor's work with this change in mind.
I was talking about timeOntrade apparently.
In timeOntrade just false at the end will not give the desired result, but in my variant opens trades by the hour is real, tested.
What happens if timeOntrade.hour = 5?
The deal certainly won't be done, because in...
//Basis for switching to Open
if(!PositionSelect(_Symbol)&& (timeOntrade(4) || ((timeOntrade(15) || timeOntrade(16))&& timeOntrade2(0)))) Open();//
...send to open only at specified time
In timontrade, it's exactly false at the end that won't produce the desired result...
alph, this is what Yedelkin is talking about.
These variants of the function are identical in our mind
By the way, in this variant the tester's result by profit is small, but the ratio seems to me to be good.
Now I am testing on larger timeframes without time reference, maybe the result will be better.