//+------------------------------------------------------------------+ //| iRhombus.mq4 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window //--- input parameters /* Параметыры: StartDate - начальная дата. Можно не трогать HeightPoints - высота WidthBars - ширина */ input datetime StartDate = 0; input int HeightPoints = 50; input int WidthBars = 10; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit(){ return(INIT_SUCCEEDED); } void OnDeinit(const int r){ ObjectsDeleteAll(0,WindowExpertName()); ChartRedraw(); } //+------------------------------------------------------------------+ //| 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[]) { Draw(); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if(id==CHARTEVENT_CHART_CHANGE){ Draw(); } } //+------------------------------------------------------------------+ void Draw(){ ObjectsDeleteAll(0,WindowExpertName()); datetime sd=MathMax(StartDate,Time[Bars-1]); int sb=iBarShift(NULL,0,sd,false); int fvb=(int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR); int db=sb-((sb-fvb)/WidthBars)*WidthBars; if(db+WidthBarsChartGetDouble(0,CHART_PRICE_MIN)/*-Point*HeightPoints*/){ fObjTrendLine(WindowExpertName()+"_"+(string)n,Time[db],sp,fMyTime(db-ws*WidthBars),ep,false); sp-=Point*HeightPoints; ep-=Point*HeightPoints; n++; } ep=sp-(Point*HeightPoints)*ws; while (ep