You do one mistake. Use this modified code and try to find answer.
static double EMA_Short_Saved=0; static double PreviousPrice=0; int start() { //---- if(!isNewBar()) { return(0); } double EMA_Short_Current = NormalizeDouble(iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 0), 4); double EMA_Short_Previous = NormalizeDouble(iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 1), 4); Print("EMA_Short_Current = " + EMA_Short_Current + ", EMA_Short_Previous = " + EMA_Short_Previous + ", EMA_Short_Saved = " + EMA_Short_Saved); if(EMA_Short_Saved != 0) if(EMA_Short_Saved != EMA_Short_Previous) Print("Something wrong ??"); EMA_Short_Saved = EMA_Short_Current; PreviousPrice=Close[0]; //---- return(0); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What I don't understand is why the variables EMA_Short_Saved and EMA_Short_Previous are not egal !!
They should be !
EMA_Short_Saved is the value of the EMA calculated at time i and saved
EMA_Short_Previous is the value of the EMA for shift = 1, calculated at time i + 1
so they should be egal.
Do I miss something ?