How to execute code on one side of moving average only?
How to execute code on one side of moving average only?
10 Apr 2020, 08:13
Hi,
I have what I think is a fairly simple request but cannot for the life of me figure it out.
I am basically looking to have an expression built in to my bot that allows me to execute only buy trades when market is above moving average, and only sell trades when market is below a defined moving average. There is no requirement to close any open trades when crossing the MA or anything like that.
I have tried building one using the code in the Sample Trend cBot included with cTrader but the problem is it will still only let me place one trade in either direction when moving average is crossed. It also uses a fast and slow moving average, which is irrelevant to me as I only need 1 moving average
So for example:
if CurrentMovingAverage <= DefinedMovingAverage
ProcessSell();
if CurrentMovingAverage >= DefinedMovingAverage
ProcessBuy();
I can provide more code if required for context / troubleshooting.
Many thanks,
Mr4x
firemyst
04 Sep 2020, 09:03
RE:
Mr4x said:
You need to say:
@firemyst