My holy grail - but EA need to be fixed

Hallo


YUMA_5_18_28_exit8_EA.zip (1.75 KB) I have created my EA on online creator. But I am not coder so I stucked.

Idea: moving averges crossover: 5 WMA cross 18 and 28 EMA upside: go LONG. CLOSE LONG when 5 WMA is less than 8 WMA.

SHORT the opposite way.

BUT the BIG BUT is that idea was that after, for example LONG position (crossover) next position should be SHORT (when next crossover)

I draw it in problem.jpg

It need to have a logical limitation to open next position on next crossover and go opposite way.

Could you fix it for me please

Michal

YUMA_5_18_28_exit8_EA.mq4.zip (1.75 KB)

Try this… it stores the info if the last order was a long or a short… the moment you reinitialize the robot(you restart the platform, the chart, the ea,etc) you lose that info… a way to always have that info regarding last order that is not affected by this is by writing that info to file and reading it from file. If you never turn off the ea you wont need it though.

Interesting idea.
I have modified the EA as requested, and I took the liberty of cleaning up the code a bit. I also added the option to edit the MA periods and SL/TP/TS levels from the MT4 Expert Properties dialog.

The EA will now only open a new position as long as it’s in the opposite direction of the previously opened position.

YUMA.zip (1.16 KB)

I tried to backtest this EA but it doesn’t put any orders.