Using the library in script

 

Hi,

Can we use the standard library in script? I'm trying to create rectangle using script and the library but nothing happen. Got no problem using ObjectCreate.

#property strict
#include <ChartObjects\ChartObjectsShapes.mqh>
CChartObjectRectangle try;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   try.Create(ChartID(),"scriptbox",0,0,0,0,0);
  }
//+------------------------------------------------------------------+

When I run the script, the rectangle is not in Object List (Ctrl+B).

But when I do it using Indicator,

#property strict
#property indicator_chart_window
#include <ChartObjects\ChartObjectsShapes.mqh>
CChartObjectRectangle try;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   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[])
  {
//---
   if(prev_calculated==0)
     {
      try.Create(ChartID(),"boxtry",0,0,0,0,0);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }

the rectangle is there in the object list.

I remember reading one of the advantages using the library when creating objects is that the object is deleted when the Indicator/EA is removed.

Does this mean that when the script is removed (automatically after completion), the rectangle is also removed?

Reason: