Cleaning All Charts

Author: Copyright © 2020, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
Cleaning All Charts
ÿþ//+------------------------------------------------------------------+

//|                                          Cleaning All Charts.mq5 |

//|                              Copyright © 2020, Vladimir Karputov |

//|                     https://www.mql5.com/ru/market/product/43516 |

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

#property copyright "Copyright © 2020, Vladimir Karputov"

#property link      "https://www.mql5.com/ru/market/product/43516"

#property version   "1.000"

#property script_show_inputs

//--- input parameters

input bool  InpComments = true;  // Clearing all comments

input bool  InpObjecsts = true;  // Removes all objects

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

//| Script program start function                                    |

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

void OnStart()

  {

//---

   if(InpComments || InpObjecsts)

     {

      //--- variables for chart ID

      long currChart,prevChart=ChartFirst();

      int i=0,limit=100;

      //--- cleaning first chart

      if(InpComments)

         ChartSetString(prevChart,CHART_COMMENT,"");

      if(InpObjecsts)

         ObjectsDeleteAll(prevChart,-1,-1);

      //--- cleaning other charts

      while(i<limit) // we have certainly not more than 100 open charts

        {

         currChart=ChartNext(prevChart); // get the new chart ID by using the previous chart ID

         if(currChart<0)

            break; // have reached the end of the chart list

         if(InpComments)

            ChartSetString(currChart,CHART_COMMENT,"");

         if(InpObjecsts)

            ObjectsDeleteAll(currChart,-1,-1);

         prevChart=currChart; // let's save the current chart ID for the ChartNext()

         i++; // do not forget to increase the counter

        }

     }

  }

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

Comments