Chart_MAX_Price

Author: 2009-2020, MetaQuotes Software Corp.
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Chart_MAX_Price
ÿþ//+------------------------------------------------------------------+

//|                                                      ProjectName |

//|                                      Copyright 2020, CompanyName |

//|                                       http://www.companyname.net |

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

#property copyright   "2009-2020, MetaQuotes Software Corp."

#property link        "http://www.mql5.com"

#property version     "1.0"

#property description "MAX_P"



#property indicator_chart_window

#property indicator_buffers 0

#property indicator_plots   0



#include <Canvas\Canvas.mqh>



CCanvas m_canvas;



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

int OnInit()

  {

   if(!m_canvas.CreateBitmapLabel("MAX_P", 10, 60, 200, 60))

     {

      Alert("Error creating canvas: ", GetLastError());

      return (INIT_FAILED);

     }

   m_canvas.FontFlagsSet(FW_BOLD);

   m_canvas.FontSizeSet(45);



   return (INIT_SUCCEEDED);

  }



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

//|                                                                  |

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

void OnDeinit(const int reason)

  {

   m_canvas.Destroy(); // destroy canvas object

   ObjectDelete(0, "MAX_P"); // delete bitmap object from chart

   ChartRedraw(0);

  }









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

//|                                                                  |

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

void OnChartEvent(const int id,

                  const long& lparam,

                  const double& dparam,

                  const string& sparam

                 )

  {



   if(id==CHARTEVENT_CHART_CHANGE)

     {



      m_canvas.Erase(ColorToARGB(clrWhiteSmoke, 1)); // clear text



      long firstVisibleBar = ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0); // first bar index on left border

      long allVisible = ChartGetInteger(0,CHART_VISIBLE_BARS,0); // number of visible bars on the screen

      int startBarIndex = (int)MathAbs(allVisible - firstVisibleBar); // an absolute number for the starting index 



      int highestI = iHighest(NULL, 0, MODE_HIGH, (int)allVisible, startBarIndex);

      int lowestI = iLowest(NULL, 0, MODE_LOW, (int)allVisible, startBarIndex);



      double a = (iHigh(NULL, 0, highestI) - iLow(NULL, 0, lowestI)) / _Point;



      m_canvas.TextOut(20, 10, DoubleToString(a, 0), clrRed);



      m_canvas.Update();

     }



  }



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

//|                                                                  |

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

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 &TickVolume[],

                const long &Volume[],

                const int &Spread[])

  {

// do nothng

   return(rates_total);

  }







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

Comments