Even more space

Author: Copyright © 2021, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
Even more space
ÿþ//+------------------------------------------------------------------+

//|                                              Even more space.mq5 |

//|                              Copyright © 2021, Vladimir Karputov |

//|                      https://www.mql5.com/en/users/barabashkakvn |

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

#property copyright "Copyright © 2021, Vladimir Karputov"

#property link      "https://www.mql5.com/en/users/barabashkakvn"

#property version   "1.00"

#property script_show_inputs

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

//| Enum percentage                                                  |

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

enum ENUM_PERCENTAGE

  {

   percent_off    = -1,    // OFF

   percent_10     = 10,    // 10

   percent_12     = 12,    // 12

   percent_14     = 14,    // 14

   percent_16     = 16,    // 16

   percent_18     = 18,    // 18

   percent_20     = 20,    // 20

   percent_22     = 22,    // 22

   percent_24     = 24,    // 24

   percent_26     = 26,    // 26

   percent_28     = 28,    // 28

   percent_30     = 30,    // 30

   percent_32     = 32,    // 32

   percent_34     = 34,    // 34

   percent_36     = 36,    // 36

   percent_38     = 38,    // 38

   percent_40     = 40,    // 40

   percent_42     = 42,    // 42

   percent_44     = 44,    // 44

   percent_46     = 46,    // 46

   percent_48     = 48,    // 48

   percent_50     = 50,    // 50

  };

//--- input parameters

input ENUM_PERCENTAGE   InputChartShift   = percent_off; // Indent from the right border

input bool              InpDateScale      = false;       // Showing the time scale on a chart

input bool              InpPriceScale     = false;       // Showing the price scale on a chart

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

//| Script program start function                                    |

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

void OnStart()

  {

//--- variables for chart ID

   long currChart,prevChart=ChartFirst();

   int i=0,limit=100;

   Print("ChartFirst =",ChartSymbol(prevChart)," ID =",prevChart);

//---

   ChartAutoscrollSet(true,prevChart);

   ChartShiftSet(true,prevChart);

   ChartShiftSizeSet((double)InputChartShift,prevChart);

   ChartShowDateScaleSet(InpDateScale,prevChart);

   ChartShowPriceScaleSet(InpPriceScale,prevChart);

//---

   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

      Print(i,ChartSymbol(currChart)," ID =",currChart);

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

      //---

      ChartAutoscrollSet(true,prevChart);

      ChartShiftSet(true,prevChart);

      ChartShiftSizeSet((double)InputChartShift,prevChart);

      ChartShowDateScaleSet(InpDateScale,prevChart);

      ChartShowPriceScaleSet(InpPriceScale,prevChart);

      //---

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

     }

//---

  }

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

//| Enables/disables automatic scrolling of a chart to the right     |

//| on new ticks arrival                                             |

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

bool ChartAutoscrollSet(const bool value,const long chart_ID=0)

  {

//--- reset the error value

   ResetLastError();

//--- set property value

   if(!ChartSetInteger(chart_ID,CHART_AUTOSCROLL,0,value))

     {

      //--- display the error message in Experts journal

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- successful execution

   return(true);

  }

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

//| Enables/disables displaying of a price chart with a shift from the right border |

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

bool ChartShiftSet(const bool value,const long chart_ID=0)

  {

//--- reset the error value

   ResetLastError();

//--- set property value

   if(!ChartSetInteger(chart_ID,CHART_SHIFT,0,value))

     {

      //--- display the error message in Experts journal

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- successful execution

   return(true);

  }

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

//| Sets the size of shifting of the zero bar from the right border             |

//| of the chart in percentage values (from 10% up to 50%).                     |

//| To enable the shift mode, CHART_SHIFT property value should be set to true. |

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

bool ChartShiftSizeSet(const double value,const long chart_ID=0)

  {

//--- reset the error value

   ResetLastError();

//--- set property value

   if(!ChartSetDouble(chart_ID,CHART_SHIFT_SIZE,value))

     {

      //--- display the error message in Experts journal

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- successful execution

   return(true);

  }

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

//| Enables/disables displaying of the time scale on chart           |

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

bool ChartShowDateScaleSet(const bool value,const long chart_ID=0)

  {

//--- reset the error value

   ResetLastError();

//--- set property value

   if(!ChartSetInteger(chart_ID,CHART_SHOW_DATE_SCALE,0,value))

     {

      //--- display the error message in Experts journal

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- successful execution

   return(true);

  }

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

//| Enables/disables displaying of the price scale on chart          |

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

bool ChartShowPriceScaleSet(const bool value,const long chart_ID=0)

  {

//--- reset the error value

   ResetLastError();

//--- set property value

   if(!ChartSetInteger(chart_ID,CHART_SHOW_PRICE_SCALE,0,value))

     {

      //--- display the error message in Experts journal

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- successful execution

   return(true);

  }

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

Comments