Help write an expert - page 5

 
However, here is code for 1 opening for one cross. Although, if the candle is too long, more than 50 pips takeProfit, another opening is possible as the EA will see the signal to open again.
Files:
 
Fduch писал(а) >>

I warned about barsToSaveSignal. Advisor "remembers" crossing bars during barsToSaveSignal

I agree with Figaro, that's how I imagined it too...

 
Fduch писал(а) >>
However, here is the code for 1 opening for one cross. Although, if the candle is too long, more than 50 pips takeProfit-a, another opening is possible as the EA will see the signal to open again.

>>Thank you, I'll try how it works.)

 
khorosh >> :
"For some reason, when the Expert Advisor closes a position on the profit side, it immediately opens a new position on the profit side without waiting for MA crossing and then once again..."

Because the global variables that give the command to open an order should be reset after they have been used once. But this is not done.

You are wrong. Vadimus asked the EA to "remember" when the MA was crossed in order to open a position even if the High or Low was not to be breached in the next one, but in 2 or 3. This is what the global variable is responsible for.

 
Fduch >> :

You are wrong. Vadimus asked the EA to "remember" when there was a cross in order to open a position, even if the High or Low is not broken at the next one, but after 2 or 3. This is what the global variable is responsible for.

I understand this and I know that a global variable is needed for this. But once the condition to open an order has been fulfilled, the global variables need to be reset.

 
Figar0 писал(а) >>

Made to the best of my understanding of the ToR, have a look

I've looked at the visualisations, so far everything looks great, at least the I/Os are absolutely correct and match the algorithm. Thank you so much!!!! Now there are a couple of little things left - optimization, demo and real)) Anyway, thanks a lot!

 
Vadimus >> :

Now there are a couple of little things left - optimization, demo and real)) Anyway, I thank you very much!

Real? This strategy??? I sincerely wish you good luck!

 
Fduch писал(а) >>

Real? This strategy...? I sincerely wish you luck!

I'm still analyzing your option, I couldn't do two at once... Why so ironic?) Is there something wrong with this strategy?

 
Vadimus >> :

Your option I'm still analysing, I couldn't have two at once... And why such irony?) Is there something wrong with this strategy?

I think Figar0 has a more reliable solution, I advise you to use his expert.

For real EA is a bit risky: no protection against news, trailing stop (at least a trivial transfer to Breakeven). In addition, the strategy will be profitable only during a trend.

 
Vadimus >> :

Your option I'm still analysing, I couldn't have two at once... And why such irony?) Is there something wrong with this strategy?

I think Figar0 has a more reliable solution, I advise you to use his expert.

For real EA is a bit risky: no protection against news, trailing stop (at least a trivial transfer to Breakeven). In addition, the strategy will be profitable only during a trend.