My first MT5 Indicator is not work,what's wrong with this code

 

I code in mt4 before, I want to learn MT5 code for several times but all failed.

The code below is my another try.

It will work in MT4 I am sure about it, but in MT5 it show nothing graphic.

I just want draw something on the chart.

Could any tell me what's wrong with my code.

I have already put data in the buffer array, and out put it by Print() to make sure the data is there.

But no graphic show on chart.

Please help me. This is a really simple and meaningless Indicator, I just want to know how MT5 show draw graphic.

This is very important for me.

Thanks .

English is not my native tongue. If I offend anyone, I really not mean it.


//+------------------------------------------------------------------+
//|                                                         test.mq5 |
//|                   Copyright 2009-2017, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2009-2017, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
#property description "Larry Williams' Percent Range"
//---- indicator settings
#property indicator_separate_window
#property indicator_level1     -20.0
#property indicator_level2     -80.0
#property indicator_levelstyle STYLE_DOT
#property indicator_levelcolor Silver
#property indicator_levelwidth 1
#property indicator_maximum    0.0
#property indicator_minimum    -100.0
#property indicator_buffers    1
#property indicator_plots      1
#property indicator_type1      DRAW_LINE
#property indicator_color1     DodgerBlue
//---- input parameters

//---- buffers
double    ExtWPRBuffer[];
//--- global variables

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {


//---- indicator's buffer   
   SetIndexBuffer(0,ExtWPRBuffer);


//----
  }
//+------------------------------------------------------------------+
//| Williams?Percent Range                                          |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int kkk=0;
   for(int i=0;i<100;i++)
     {
      ExtWPRBuffer[i]=kkk;
      Print("i=",i," buffer=",ExtWPRBuffer[i]);
      kkk++;
     }

//--- return new prev_calculated value
   return(rates_total);
  }
I
 

Please check this indicator

Files:
Test.mq5  3 kb
 
Biantoro Kunarto:

Please check this indicator

thank you very much.

ArraySetAsSeries(ExtWPRBuffer,true);

In your file this function make the Indicator worked.

Can I consider the difference between MT4 and MT5 is

MT4 set array default in time series, but MT5 is not time series by default ?

 
Ma Yuliang:

thank you very much.

In your file this function make the Indicator worked.

Can I consider the difference between MT4 and MT5 is

MT4 set array default in time series, but MT5 is not time series by default ?

I think so, but I am not so sure about it :)

 
Biantoro Kunarto:

I think so, but I am not so sure about it :)

You can be sure.
 
Alain Verleyen:
You can be sure.
Thanks Alain :)