Can't draw to the window.

 

Moving from mql4 to mql5 but can't even draw a rectangle,

tried:

ObjectCreate(0, "Rectangle", OBJ_RECTANGLE, 0, time[0], 1, time[5], 2)

just to get going but nothing is showing.

What's wrong?

Here's the full code:

#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---
   ObjectCreate(0, "Rectangle", OBJ_RECTANGLE, 0, time[0], 1, time[5], 2);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Thanks.;‌

 
paulgriffiths:

Moving from mql4 to mql5 but can't even draw a rectangle,

tried:

ObjectCreate(0, "Rectangle", OBJ_RECTANGLE, 0, time[0], 1, time[5], 2)

just to get going but nothing is showing.

What's wrong?

Here's the full code:

#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---
   ObjectCreate(0, "Rectangle", OBJ_RECTANGLE, 0, time[0], 1, time[5], 2);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Thanks.;‌

time[] is not indexed as series by default with mql5.

Add a line before ObjectCreate() :

ArraySetAsSeries(time,true);

‌Also I suppose price between 1 and 2 are visible on your chart.

Finally ObjectCreate() is a function, you should always check the return value.‌

 

Thanks, that worked for the rectangle.

Seems the same or buffers too

Thanks man..‌