HLine Add Description

Author: Copyright © 2020, Vladimir Karputov
Price Data Components
0 Views
0 Downloads
0 Favorites
HLine Add Description
ÿþ//+------------------------------------------------------------------+

//|                                        HLine Add Description.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 indicator_chart_window

#property indicator_buffers      0

#property indicator_plots        0

//--- input parameters

input bool     InpPrintLog          = false;       // Print log

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

//| 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[])

  {

//---

//--- return value of prev_calculated for next call

   return(rates_total);

  }

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

//| ChartEvent function                                              |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

//--- the object has been created

   if(id==CHARTEVENT_OBJECT_CREATE)

     {

      long obj_type=ObjectGetInteger(0,sparam,OBJPROP_TYPE);

      if(obj_type!=OBJ_HLINE)

         return;

      double hline_price=ObjectGetDouble(0,sparam,OBJPROP_PRICE);

      ObjectSetString(0,sparam,OBJPROP_TEXT,DoubleToString(hline_price,Digits()));

      ChartRedraw(0);

      if(InpPrintLog)

         Print("The object with name ",sparam," has been created");

     }

//--- the object has been moved or its anchor point coordinates has been changed

   if(id==CHARTEVENT_OBJECT_DRAG)

     {

      long obj_type=ObjectGetInteger(0,sparam,OBJPROP_TYPE);

      if(obj_type!=OBJ_HLINE)

         return;

      double hline_price=ObjectGetDouble(0,sparam,OBJPROP_PRICE);

      ObjectSetString(0,sparam,OBJPROP_TEXT,DoubleToString(hline_price,Digits()));

      ChartRedraw(0);

      if(InpPrintLog)

         Print("The anchor point coordinates of the object with name ",sparam," has been changed");

     }

//--- the text in the Edit of object has been changed

  }

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

Comments