Thank you for writing in. You have errors in the code you provided such as "fastSma" and "fastDma" which are not declared variables. Please make sure you have debugged your code prior to beginning the changes I discuss below.
To change the EMA to SMA, the simplest way is to leave all the variable names the same, and just to change the logic. Please locate the following section of code:
fastEma.Set((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * fastEma[1]); slowEma.Set((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * slowEma[1]);
fastEma.Set(SMA(Fast)[0]); slowEma.Set(SMA(Slow)[0]);
if(CrossAbove(Value, Avg, 1)) { above = true; Alert("CrossAboveAlert", NinjaTrader.Cbi.Priority.High, "Crossed Above", "Alert1.wav", 1, Color.Black, Color.Yellow); } else if (CrossBelow(Value, Avg, 1)) { above = false; Alert("CrossBelowAlert", NinjaTrader.Cbi.Priority.High, "Crossed Below", "Alert1.wav", 1, Color.Black, Color.Yellow); }
Please let me know if I may be of further assistance.
Leave a comment: