why my EMA is horizontal line ?

 

i am just a beginner , i tried to draw a EMA on the chart but obviously it is failed.which part i did it wrong ?

int start()
  {
   double EMA=iMA(_Symbol,PERIOD_CURRENT,200,0,MODE_EMA,PRICE_CLOSE,0);
   ObjectCreate("MA",OBJ_TREND,0,Time[0],EMA,Time[Bars-1],EMA);
   ObjectSet("MA",OBJPROP_COLOR,Red);

//---


   return(0);
  }
 
Jason Andy: .which part i did it wrong ?
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. You created a line from the current candle to the earliest one using the same price; the definition of horizontal.
  3. Also remember, you can't get an n period moving average until you have n candles.
 
William Roeder #:
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. You created a line from the current candle to the earliest one using the same price; the definition of horizontal.
  3. Also remember, you can't get an n period moving average until you have n candles.
i know which part i got wrong , the iMA's shift ;)