Plotting SMA indicator on chart

 

For my first indicator, I'm simply trying to plot the SMA indicator on a chart. I can get the code to compile and it loads when I click "Start on Real Data," but nothing actually shows on the chart. What is going wrong here?

 

#property copyright "Copyright 2016, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict


#property indicator_chart_window

#property indicator_buffers 1


//Overlay 200-period SMA over chart


int smaPeriod = 200;

double SMA200[];


int OnInit() { 

   SetIndexBuffer(0, SMA200);


   return(INIT_SUCCEEDED);

  }

  

  int Start() {

   int i; //Used to keep track of place in SMA200 array

   int countedBars = IndicatorCounted();

   i = Bars - countedBars - 1;

   while (i>=1)

      { 

      SMA200[i] = iMA(Symbol(), 0, smaPeriod, 0, 0, 0, 0);

      i--;

      }

  return 0;

  }


void OnDeinit(const int reason)

  {

//---

   

  }


void OnTick()

  {

//---

   

  }

//+------------------------------------------------------------------+

//| Tester function                                                  |

//+------------------------------------------------------------------+

double OnTester()

  {

//---

   double ret=0.0;

//---


//---

   return(ret);

  }

  

  int OnCalculate (const int rates_total,      // size of input time series

                 const int prev_calculated,  // bars handled in previous call

                 const datetime& time[],     // Time

                 const double& open[],       // Open

                 const double& high[],       // High

                 const double& low[],        // Low

                 const double& close[],      // Close

                 const long& tick_volume[],  // Tick Volume

                 const long& volume[],       // Real Volume

                 const int& spread[]         // Spread

   ) {return 0;}

//+------------------------------------------------------------------+

//| ChartEvent function                                              |

//+------------------------------------------------------------------+

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

//---

   

  }

 

Thanks to anyone that can help. 

 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. int Start() {
       int i; //Used to keep track of place in SMA200 array
    :
    }
    void OnTick(){
       //---
    }
    int OnCalculate (const int rates_total,      // size of input time series
       :
    Perhaps you should read the manual. Especially Event Handling Functions - Functions - Language Basics - MQL4 Reference Old type: int start(), New type: OnCalculate().  There is no Start(), and indicators have no OnTick().
  3. SMA200[i] = iMA(Symbol(), 0, smaPeriod, 0, 0, 0, 0);
    Why are you setting every bar with the same value?
  4. Do your lookbacks correctly.
Reason: