Hi there, I wonder if anyone can help me please? I am new to coding so sorry if asking basic questions.
I would like to do the following:
Automate closing a trade (short or long) when the fast moving average crosses the slower moving average against the trend if that makes sense?
The Pseudo Code Version..
1, check current fast moving average and slow average against previous result,
2, If a long position and fast average above the slow average or not touching keep trade open,
3 If a short trade - Close trade,
4, If a short position and fast average below or not touching the slow average keep trade open, 5, If a long trade - Close trade
This is what I came up to close the Long Position, I placed it On Tick however the trades do not close-
if (currentFastMa <= currentSlowMa && shortPosition == Null)
ClosePosition(LongPosition);
Have no idea if this is too simple or I need to reference previous periods or what I have missed.
Hoping someone more experienced is happy to help and share their knowledge!
Thanks in advance