MA and Price - MetaTrader 4 Expert | MT4 EA Download - MetaTrader 4 Resources



Of course, this system is not new, but that's not the point. I can't implement something correctly to test it properly. Also, I really need this functionality in other ATSs. (In its current form, it only helps those who actually have extra funds).
More specifically, I am unable to achieve a position reversal. The current state of the program is implemented as follows:
Short position First candle: Close price is above MA (buy signal) Second candle: Close the short position at the opening price of the new candle (at this time a long position must be opened) Third candle: (This is where the error occurs) Open a long position at the opening price of this candle (not the second candle).
This process is shown in the figure (using "buy" to describe the situation, which is of course the same as "sell").
I would be happy if minds more advanced than mine could help solve this task. If possible, please fix the attached code. Of course I would also appreciate simple tips. (Though I'm not sure I'd be able to translate the simple trick into code - too little experience). :)

Attachment download
📎 oc08_vy_m0moqesu15.mq4 (6.91 KB)
Source: MQL5 #8615
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •