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.