Draw remaining graphics object to chart from script

 

I would like to draw some graphics to the chart from a script.

I use the standard library classes and objects.

I would like to keep the objects on the chart after the script finished,

but the objects destructor automatically clean them.

 

How can I draw remaining objects from a script? 

 
totati:

I would like to draw some graphics to the chart from a script.

I use the standard library classes and objects.

I would like to keep the objects on the chart after the script finished,

but the objects destructor automatically clean them.

 

How can I draw remaining objects from a script? 

Recheck your code.
 

Dear Sir

I don't know what exactly you think, but here is my test code:

#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

#include <ChartObjects\ChartObjectsTxtControls.mqh>

CChartObjectText  bar_info;

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   MqlRates rates[];

   ArraySetAsSeries(rates, true);
   int copied = CopyRates(_Symbol, PERIOD_CURRENT, 0, 10, rates);
  
   if(copied > 0)
   {
      bar_info.Create(0, "Info", 0, rates[5].time, rates[5].high);

      bar_info.Description("H E L L O");     // I need permanent text on the chart
   }

   Sleep(2000);
}

When I write to a chart with the common method:

ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price)

the text object remains on the chart, but in OOP it is cleand, so I can not use the standard library.

I'm learning now the OOP concept and I think that the CChartObjectText destructor clean my text

from the chart. I don't want to run this script continuously.

 
totati:
...
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   MqlRates rates[];

   ArraySetAsSeries(rates, true);
   int copied = CopyRates(_Symbol, PERIOD_CURRENT, 0, 10, rates);
  
   if(copied > 0)
   {
      bar_info.Create(0, "Info", 0, rates[5].time, rates[5].high);

      bar_info.Description("H E L L O");     // I need permanent text on the chart

      bar_info.Detach();
   }

}
 
Alain Verleyen:

Dear Alain, yes it is, thank you very much,

I did not understand well the documentation...