Crossing EMAs
Created at 07 May 2018, 02:15
ZA
Crossing EMAs
07 May 2018, 02:15
Hi, I have problems with the following code, I need the cbot not to execute operations when a fast EMA goes against the long-term EMA, but I dont get it. I need for example, when the fast EMA crosses up the long-term EMA, purchase orders are executed whenever the fast EMA continues to rise, but when it starts to decrease, stop putting operations until it crosses back to the long-term EMA and reverse the direction of operations
if (EmaFast.Result.Last(0) < EmaSlow.Result.Last(0) && EmaFast.Result.Last(0) < EmaFast.Result.Last(1)) { Buy = false; Sell = true; } else if (EmaFast.Result.Last(0) > EmaSlow.Result.Last(0) && EmaFast.Result.Last(0) > EmaFast.Result.Last(1)) { Buy = true; Sell = false; } else { Buy = false; Sell = false; }