Author: Copyright 2019, Ridge Wang.

Okay, here's a description of what the MQL4 script does, explained in plain language for someone who isn't a programmer:

Overall Purpose:

This script is designed to visually represent the progress of different timeframes (like 1-minute, 5-minute, 15-minute, 30-minute, and 1-hour charts) all on a single chart. It also gives some information about the price movement (range) within each of those timeframes.

How it Works:

  1. Visual Display:

    • It creates a set of buttons and progress bars in a separate window of your trading chart.
    • Each row represents a different timeframe (M1, M5, M15, M30, H1).
    • Each row shows a progress bar indicating how far along the current candle is in that timeframe. For example, if it's halfway through the current 5-minute candle, the "M5" progress bar will be 50% full.
    • The script displays the progress for each timeframe in percentage and time format.
  2. Price Range Information:

    • Alongside the progress bar, each row includes:
      • The current price range for that specific timeframe?s current candle. It shows the difference between the open and close price, as well as the total range of the candle (from the lowest to highest price).
      • Up/Down indicators of price to show price movements.
  3. Technical Indicator (Stochastic Oscillator):

    • The script can use a Stochastic Oscillator to determine the values if a setting is selected to do so.
  4. Customization:

    • The script has a number of adjustable settings (inputs). These include colors for the buttons, the font size, button height, maximum candle width, indicator parameters for iBands and Stochastic Oscillator.
  5. Underlying Calculations:

    • Time Tracking: The script constantly calculates how much time has passed in the current candle for each timeframe.
    • Percentage Completion: It converts the elapsed time into a percentage to fill the progress bars.
    • Price Range Calculation: It determines the high, low, open, and close prices for the current candle of each timeframe.
  6. Event Handling:

    • The script reacts to mouse clicks on the created buttons. It is set to work for Stochastics data, and restores chart data according to selections.

In essence, this script provides a quick way to visualize how different timeframes are progressing and what the price action has been within those timeframes, all in one place.

Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open time of each barSeries array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Indicators Used
Bollinger bands indicatorStochastic oscillator
2 Views
0 Downloads
0 Favorites
EagleEyed
ÿþ//+------------------------------------------------------------------+

//|                                                    EagleEyed.mq4 |

//|                                      Copyright 2019, Ridge Wang. |

//|                                            https://www.fixea.app |

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

#property copyright "Copyright 2019, Ridge Wang."

#property link      "https://www.fixea.app"

#property version   "1.00"

#property description "Display five timeframe chart progress in one Char, Within One Hour!"

#property description "wechat:qq12035729, email@qinjun.wang"

#property strict



#property indicator_separate_window

#property indicator_minimum 0

#property indicator_maximum 120

#property indicator_buffers 5

#property indicator_plots   5



//--- plot lblM1

#property indicator_label1  "M1"

#property indicator_type1   DRAW_LINE

#property indicator_color1  clrGray

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1



//--- plot lblM5

#property indicator_label2  "M5"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrRed

#property indicator_style2  STYLE_DOT

#property indicator_width2  1



//--- plot lblM15

#property indicator_label3  "M15"

#property indicator_type3   DRAW_LINE

#property indicator_color3  clrGold

#property indicator_style3  STYLE_DOT

#property indicator_width3  1



//--- plot lblM30

#property indicator_label4  "M30"

#property indicator_type4   DRAW_LINE

#property indicator_color4  clrDarkViolet

#property indicator_style4  STYLE_DOT

#property indicator_width4  1



//--- plot lblH1

#property indicator_label5  "H1"

#property indicator_type5   DRAW_LINE

#property indicator_color5  clrDarkBlue

#property indicator_style5  STYLE_DOT

#property indicator_width5  1

//--- input parameters



extern string LayoutBlockSettings="-------Layout Setting-------";

extern color ButtonDefaultBackColor = clrOldLace;                //Backgroud Color

extern color ButtonShadowBackColor = clrGray;                    //Shadow Background color

extern color BorderColor = clrBlack;                             //Object Border Color

extern long  DisplayFontSize = 7;                                //Font Size (Points)

extern long  ButtonStdHeight = 12;                               //Standard Button Height

extern long  CandleRangeMaxWidth = 240;                          //Candle Max Width

extern string iBandsBlockSettings="-------Indicator Parameters-------";

extern long IndicatorBtnWidth = 80;                               //

extern int iBandsPeriod = 20;                                     //iBands Period

extern double iBandsDeviation = 2.0;                              //iBands Deviation

extern ENUM_APPLIED_PRICE iBandsPrice = PRICE_CLOSE;              //iBands Price Mode

extern int iBansMiddlePoints = 20;                                //Offset points of Middle Line

extern color iBansUpperMiddleColor = clrDodgerBlue;               //Over Middle Color

extern color iBansLowerMiddleColor = clrMagenta;                  //Lover Middle Color

extern color iBansOutOfColor = clrRed;                            //Out of Range Color

extern string KDJBlock="-------Stoch Parameters(5,3,3)-------";

extern bool   useStoReplacePecent=true;                           //Use Stoch value with Candle Percent

extern int    kdj_k     = 5;

extern int    kdj_d     = 3;

extern int    kdj_slow  = 3;



//--- indicator buffers

double         lblM1Buffer[];

double         lblM5Buffer[];

double         lblM15Buffer[];

double         lblM30Buffer[];

double         lblH1Buffer[];



string myProgName=MQLInfoString(MQL_PROGRAM_NAME);

string strIndicatorShortName = StringConcatenate(myProgName, " (", indicator_label1, ",", indicator_label2, ",", indicator_label3, ",", indicator_label4, ",", indicator_label5, ")");

long PanelObjectCreateZOrder = 0;



string objItems[];

string objIdList = "btnH1Prog;btnH1Up;btnH1;btnH1Down;btnM30Prog;btnM30Up;btnM30;btnM30Down;btnM15Prog;btnM15Up;btnM15;btnM15Down;btnM5Prog;btnM5Up;btnM5;btnM5Down;btnM1Prog;btnM1Up;btnM1;btnM1Down";

string objPrefix = "ege_";



double lastBid = 0.00;

double lastAsk = 0.00;

double currentMinPrice = 0.00;

double currentMaxPrice = 0.00;

double currentZoomPercent=1.00;

int allFrames[];



int   AnalyzeLabelWindow=0;

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

   ArrayResize(allFrames,9);

   allFrames[0] = PERIOD_M1;

   allFrames[1] = PERIOD_M5;

   allFrames[2] = PERIOD_M15;

   allFrames[3] = PERIOD_M30;

   allFrames[4] = PERIOD_H1;

   allFrames[5] = PERIOD_H4;

   allFrames[6] = PERIOD_D1;

   allFrames[7] = PERIOD_W1;

   allFrames[8] = PERIOD_MN1;



   EventSetTimer(1);//Every Second

   IndicatorDigits(2); //Percent and Sotch value use the same two digits



//--- indicator buffers mapping

   SetIndexBuffer(0,lblM1Buffer);

   SetIndexBuffer(1,lblM5Buffer);

   SetIndexBuffer(2,lblM15Buffer);

   SetIndexBuffer(3,lblM30Buffer);

   SetIndexBuffer(4,lblH1Buffer);



   IndicatorShortName(strIndicatorShortName);

   AnalyzeLabelWindow=GetIndicatorWindow();



   if(useStoReplacePecent==false)

     {

      SetLevelValue(0,50.00);

      SetLevelValue(1,100.00);

     }

   else

     {

      SetLevelValue(0, 20.00);

      SetLevelValue(1, 80.00);

     }

   SetLevelStyle(STYLE_DOT,1,clrGray);



   string sep=";";

   ushort u_sep=StringGetCharacter(sep,0);

   int k=StringSplit(objIdList,u_sep,objItems);



   BuildCandleMix();



//---

   return(INIT_SUCCEEDED);

  }

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

//|                                                                  |

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

void OnDeinit(const int reason)

  {

//--- destroy timer

   EventKillTimer();



   Comment("");



   int itemCount=ArraySize(objItems);

   for(int i=0;i<itemCount;i++)

     {

      ObjectDelete(0,objPrefix+objItems[i]);

     }



   if(reason==REASON_INITFAILED)

     {

      ChartIndicatorDelete(0,GetIndicatorWindow(),strIndicatorShortName);

     }



//--- The first way to get the uninitialization reason code 

//Print(__FUNCTION__,"_Uninitalization reason code = ",reason); 

//--- The second way to get the uninitialization reason code 

//Print(__FUNCTION__,"_UninitReason = ",getUninitReasonText(_UninitReason)); 



  }

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

//| get text description                                             | 

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

string getUninitReasonText(int reasonCode)

  {

   string text="";

//--- 

   switch(reasonCode)

     {

      case REASON_ACCOUNT:

         text="Account was changed";break;

      case REASON_CHARTCHANGE:

         text="Symbol or timeframe was changed";break;

      case REASON_CHARTCLOSE:

         text="Chart was closed";break;

      case REASON_PARAMETERS:

         text="Input-parameter was changed";break;

      case REASON_RECOMPILE:

         text="Program "+__FILE__+" was recompiled";break;

      case REASON_REMOVE:

         text="Program "+__FILE__+" was removed from chart";break;

      case REASON_TEMPLATE:

         text="New template was applied to chart";break;

      default:text="Another reason";

     }

//--- 

   return text;

  }

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

//|                                                                  |

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

bool getIBandsOfPeriod(double &iBandsVal[],int period,int shift=0)

  {

   iBandsVal[0] = iBands(NULL, period, iBandsPeriod, iBandsDeviation, 0, iBandsPrice, MODE_LOWER, shift);

   iBandsVal[1] = iBands(NULL, period, iBandsPeriod, iBandsDeviation, 0, iBandsPrice, MODE_MAIN, shift);

   iBandsVal[2] = iBands(NULL, period, iBandsPeriod, iBandsDeviation, 0, iBandsPrice, MODE_UPPER, shift);

   return true;

  }

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

//|                                                                  |

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

string PeriodStr(int intPeriod)

  {

   switch(intPeriod)

     {

      case PERIOD_MN1: return ("Monthly");

      case PERIOD_W1:  return ("Weekly");

      case PERIOD_D1:  return ("Daily");

      case PERIOD_H4:  return ("H4");

      case PERIOD_H1:  return "H1";

      case PERIOD_M30: return ("M30");

      case PERIOD_M15: return "M15";

      case PERIOD_M5:  return "M5";

      case PERIOD_M1:  return "M1";

      default:           return ("UnknownPeriod");

     }

  }

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

//|                                                                  |

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

double calcPercent(string symbol,ENUM_TIMEFRAMES timeframe,datetime timeCurrent)

  {

   long tNow=(long)timeCurrent;

   int totalSeconds=PeriodSeconds(timeframe);

   int bShift=iBarShift(symbol,timeframe,timeCurrent);

   datetime tStart=iTime(symbol,timeframe,bShift);    //Bar Start Time

   long ltStart=(long)tStart;

   long elapsedS=(tNow==ltStart) ? 0:(tNow-1-ltStart);

   return ((double)elapsedS/(double)totalSeconds)*100.00;

  }

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

//|                                                                  |

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

string TimeStrMinutes(datetime time)

  {

   return TimeToStr(time,TIME_MINUTES);

  }

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

//|                                                                  |

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

string inNextStepStr(string symbol,ENUM_TIMEFRAMES timeframe)

  {

   datetime tNow=TimeCurrent();    //Current Time

   long ltNow=(long)tNow;

   ENUM_TIMEFRAMES oldTimeFrame=timeframe;

   if(HasNextTimeFrame(timeframe,true))

     {

      int totalSeconds=PeriodSeconds(timeframe);

      datetime tStart=iTime(symbol,timeframe,0);    //Bar Start Time



      int pShift=0;

      string passedPriceStr="",stepStr=" ’! ";

      datetime passedTime=iTime(symbol,oldTimeFrame,pShift);

      while(passedTime>=tStart)

        {

         double openPrice=iOpen(symbol,oldTimeFrame,pShift);

         double closePrice= iClose(symbol,oldTimeFrame,pShift);

         double highPrice = iHigh(symbol,oldTimeFrame,pShift);

         double lowPrice = iLow(symbol, oldTimeFrame, pShift);

         double midPrice = (openPrice + closePrice)/2.0;

         passedPriceStr=StringConcatenate(stepStr,DoubleToStr(midPrice,Digits),

                                          "(",OffsetPoints(openPrice,closePrice),"/",MathAbs(OffsetPoints(lowPrice,highPrice)),") pips",

                                          passedPriceStr);

         pShift++;

         passedTime=iTime(symbol,oldTimeFrame,pShift);

        }



      long ltStart=(long)tStart;

      long elapsedS=(ltNow==ltStart) ? 0:(ltNow-ltStart);

      return StringConcatenate(PeriodStr(timeframe), ": ", DoubleToStr(((double)elapsedS/(double)totalSeconds), 2) , "(" ,

                               TimeStrMinutes(tStart),"-",TimeStrMinutes(tNow),") 0",StringSubstr(passedPriceStr,StringLen(stepStr))," 0");

     }

   return "N/A";

  }

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

//|                                                                  |

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

void BuildCandleMix()

  {

   long offsetY = 20;

   long offsetX = IndicatorBtnWidth;

   long progDiff= 5;

   long shadowHeight=ButtonStdHeight/2;



   ButtonCreate(objPrefix+"btnH1Prog",clrWhite,0,offsetY,"1/4",IndicatorBtnWidth-progDiff,ButtonStdHeight,"Progress H4");

   ButtonCreate(objPrefix+"btnH1Up",clrRed,offsetX,offsetY+shadowHeight/2,"",40,shadowHeight,"H1 Up Shadow");

   ButtonCreate(objPrefix+"btnH1",clrRed,40,offsetY,"H1",80,ButtonStdHeight,"Price Range of H1");

   ButtonCreate(objPrefix+"btnH1Down",clrRed,120,offsetY+shadowHeight/2,"",40,shadowHeight,"H1 Down Shadow");



   offsetY+=ButtonStdHeight+1;

   ButtonCreate(objPrefix+"btnM30Prog",clrWhite,0,offsetY,"1/2",IndicatorBtnWidth-progDiff,ButtonStdHeight,"Progress M30");

   ButtonCreate(objPrefix+"btnM30Up",clrRed,offsetX,offsetY+shadowHeight/2,"",40,shadowHeight,"M30 Up Shadow");

   ButtonCreate(objPrefix+"btnM30",clrRed,40,offsetY,"M30",80,ButtonStdHeight,"Price Range of M30");

   ButtonCreate(objPrefix+"btnM30Down",clrRed,120,offsetY+shadowHeight/2,"",40,shadowHeight,"M30 Down Shadow");



   offsetY+=ButtonStdHeight+1;

   ButtonCreate(objPrefix+"btnM15Prog",clrWhite,0,offsetY,"1/4",IndicatorBtnWidth-progDiff,ButtonStdHeight,"Progress M15");

   ButtonCreate(objPrefix+"btnM15Up",clrRed,offsetX,offsetY+shadowHeight/2,"",40,shadowHeight,"M15 Up Shadow");

   ButtonCreate(objPrefix+"btnM15",clrRed,40,offsetY,"M15",80,ButtonStdHeight,"Price Range of M15");

   ButtonCreate(objPrefix+"btnM15Down",clrRed,120,offsetY+shadowHeight/2,"",40,shadowHeight,"M15 Down Shadow");



   offsetY+=ButtonStdHeight+1;

   ButtonCreate(objPrefix+"btnM5Prog",clrWhite,0,offsetY,"1/12",IndicatorBtnWidth-progDiff,ButtonStdHeight,"Progress M5");

   ButtonCreate(objPrefix+"btnM5Up",clrRed,offsetX,offsetY+shadowHeight/2,"",40,shadowHeight,"M5 Up Shadow");

   ButtonCreate(objPrefix+"btnM5",clrRed,40,offsetY,"M5",80,ButtonStdHeight,"Price Range of M5");

   ButtonCreate(objPrefix+"btnM5Down",clrRed,120,offsetY+shadowHeight/2,"",40,shadowHeight,"M5 Down Shadow");



   offsetY+=ButtonStdHeight+1;

   ButtonCreate(objPrefix+"btnM1Prog",clrWhite,0,offsetY,"1/60",IndicatorBtnWidth-progDiff,ButtonStdHeight,"Progress M1");

   ButtonCreate(objPrefix+"btnM1Up",clrRed,offsetX,offsetY+shadowHeight/2,"",40,shadowHeight,"M1 Up Shadow");

   ButtonCreate(objPrefix+"btnM1",clrRed,40,offsetY,"M1",80,ButtonStdHeight,"Price Range of M1");

   ButtonCreate(objPrefix+"btnM1Down",clrRed,120,offsetY+shadowHeight/2,"",40,shadowHeight,"M1 Down Shadow");

  }

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

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

  {

//---



   lastBid = Bid;

   lastAsk = Ask;



//------------------

   int counted_bars=IndicatorCounted();

   if(counted_bars>0) counted_bars--;

   int limit=Bars-counted_bars;

   if(useStoReplacePecent && limit<300) limit=300;

   for(int i=0; i<limit; i++)

     {

      if(useStoReplacePecent)

        {



         if(crtStoData=="M1" || crtStoData=="")

           {

            lblM1Buffer[i]=iStochastic(NULL,PERIOD_M1,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

            if(crtStoData=="M1")

               lblH1Buffer[i]=iStochastic(NULL,PERIOD_M1,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_MAIN,i);

           }



         if(crtStoData=="M5" || crtStoData=="")

           {

            lblM5Buffer[i]=iStochastic(NULL,PERIOD_M5,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

            if(crtStoData=="M5")

               lblM1Buffer[i]=iStochastic(NULL,PERIOD_M5,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_MAIN,i);

           }



         if(crtStoData=="M15" || crtStoData=="")

           {

            lblM15Buffer[i]=iStochastic(NULL,PERIOD_M15,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

            if(crtStoData=="M15")

               lblM5Buffer[i]=iStochastic(NULL,PERIOD_M15,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_MAIN,i);

           }



         if(crtStoData=="M30" || crtStoData=="")

           {

            lblM30Buffer[i]=iStochastic(NULL,PERIOD_M30,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

            if(crtStoData=="M30")

               lblM15Buffer[i]=iStochastic(NULL,PERIOD_M30,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_MAIN,i);

           }



         if(crtStoData=="H1" || crtStoData=="")

           {

            lblH1Buffer[i]= iStochastic(NULL,PERIOD_H1,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

            if(crtStoData == "H1")

               lblM30Buffer[i]=iStochastic(NULL,PERIOD_H1,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_MAIN,i);

           }

        }

      else

        {

         datetime tCurrent=(i<1) ? TimeCurrent() : iTime(Symbol(),PERIOD_M1,i-1);

         lblM1Buffer[i] = calcPercent(Symbol(), PERIOD_M1, tCurrent);

         lblM5Buffer[i] = calcPercent(Symbol(), PERIOD_M5, tCurrent);

         lblM15Buffer[i] = calcPercent(Symbol(), PERIOD_M15, tCurrent);

         lblM30Buffer[i] = calcPercent(Symbol(), PERIOD_M30, tCurrent);

         lblH1Buffer[i]=calcPercent(Symbol(),PERIOD_H1,tCurrent);

        }



     }



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

   return(rates_total);

  }

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

//| Timer function                                                   |

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

void OnTimer()

  {

//---

   datetime timeNow=TimeCurrent();

   UpdatePeriodButtons(timeNow,PERIOD_H1,objPrefix+"btnH1");

   UpdatePeriodButtons(timeNow,PERIOD_M30,objPrefix+"btnM30");

   UpdatePeriodButtons(timeNow,PERIOD_M15,objPrefix+"btnM15");

   UpdatePeriodButtons(timeNow,PERIOD_M5,objPrefix+"btnM5");

   UpdatePeriodButtons(timeNow,PERIOD_M1,objPrefix+"btnM1");

  }

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

//|                                                                  |

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

void restoreDataChart(string chartPeriod)

  {

   int limit=Bars;

   if(chartPeriod!="") clearDataChart();

   for(int i=0; i<limit; i++)

     {

      if(chartPeriod=="")

        {

         lblM1Buffer[i] = iStochastic(NULL, PERIOD_M1, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_SIGNAL, i);

         lblM5Buffer[i] = iStochastic(NULL, PERIOD_M5, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_SIGNAL, i);

         lblM15Buffer[i] = iStochastic(NULL, PERIOD_M15, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_SIGNAL, i);

         lblM30Buffer[i] = iStochastic(NULL, PERIOD_M30, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_SIGNAL, i);

         lblH1Buffer[i]=iStochastic(NULL,PERIOD_H1,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

        }

      else

        {

         if(crtStoData=="M1")

           {

            lblM1Buffer[i] = iStochastic(NULL, PERIOD_M1, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_SIGNAL, i);

            lblH1Buffer[i] = iStochastic(NULL, PERIOD_M1, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_MAIN, i);

           }

         else if(crtStoData=="M5")

           {

            lblM5Buffer[i] = iStochastic(NULL, PERIOD_M5, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_SIGNAL, i);

            lblM1Buffer[i] = iStochastic(NULL, PERIOD_M5, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_MAIN, i);

           }

         else if(crtStoData=="M15")

           {

            lblM15Buffer[i]= iStochastic(NULL,PERIOD_M15,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

            lblM5Buffer[i] = iStochastic(NULL,PERIOD_M15,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_MAIN,i);

           }

         else if(crtStoData=="M30")

           {

            lblM30Buffer[i] = iStochastic(NULL, PERIOD_M30, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_SIGNAL, i);

            lblM15Buffer[i] = iStochastic(NULL, PERIOD_M30, kdj_k, kdj_d, kdj_slow, MODE_SMA, 0, MODE_MAIN, i);

           }

         else if(crtStoData=="H1")

           {

            lblH1Buffer[i]=iStochastic(NULL,PERIOD_H1,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_SIGNAL,i);

            lblM30Buffer[i]=iStochastic(NULL,PERIOD_H1,kdj_k,kdj_d,kdj_slow,MODE_SMA,0,MODE_MAIN,i);

           }

        }

     }

  }

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

//|                                                                  |

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

void clearDataChart()

  {

   ArrayInitialize(lblM1Buffer, 0.00);

   ArrayInitialize(lblM5Buffer, 0.00);

   ArrayInitialize(lblM15Buffer, 0.00);

   ArrayInitialize(lblM30Buffer, 0.00);

   ArrayInitialize(lblH1Buffer,0.00);

  }



string crtStoData="";

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

//| ChartEvent function                                              |

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

void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)

  {

//---

   int prefixLen=StringLen(objPrefix);

   if(id==CHARTEVENT_OBJECT_CLICK && StringLen(sparam)>prefixLen && StringSubstr(sparam,0,prefixLen)==objPrefix)

     {

      if(sparam==objPrefix+"btnM1Prog")

        {

         crtStoData=(crtStoData=="M1") ? "":"M1";

         restoreDataChart(crtStoData);

         return;

        }

      if(sparam==objPrefix+"btnM5Prog")

        {

         crtStoData=(crtStoData=="M5") ? "":"M5";

         restoreDataChart(crtStoData);

         return;

        }

      if(sparam==objPrefix+"btnM15Prog")

        {

         crtStoData=(crtStoData=="M15") ? "":"M15";

         restoreDataChart(crtStoData);

         return;

        }

      if(sparam==objPrefix+"btnM30Prog")

        {

         crtStoData=(crtStoData=="M30") ? "":"M30";

         restoreDataChart(crtStoData);

         return;

        }

      if(sparam==objPrefix+"btnH1Prog")

        {

         crtStoData=(crtStoData=="H1") ? "":"H1";

         restoreDataChart(crtStoData);

         return;

        }



      //::Print(__FUNCTION__," unhandled OBJECT_CLICK > id: ",id,"; lparam: ",lparam,"; dparam: ",dparam,"; sparam: ",sparam);



     }

  }

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



int GetIndicatorWindow()

  {

   int wIdx = WindowFind(strIndicatorShortName);

   if(wIdx != -1)

      return wIdx;

   return WindowFind(myProgName);

  }

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

//|                                                                  |

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

void ButtonCreate(string name,color yanse,long x,long y,string text,long width,long height=20,string toolTip="\n",string btnFont="Tahoma")

  {

   ObjectCreate(0,name,OBJ_BUTTON,GetIndicatorWindow(),0,0);

   ObjectSetInteger(0,name,OBJPROP_COLOR,yanse);

   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,ButtonDefaultBackColor);

   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);

   if(width==0)

     {

      int iStrLen=StringLen(text);

      ObjectSetInteger(0,name,OBJPROP_XSIZE,iStrLen*17);

     }

   else

     {

      ObjectSetInteger(0,name,OBJPROP_XSIZE,width);

     }

   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,true);

   ObjectSetInteger(0,name,OBJPROP_SELECTED,false);

   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);

   ObjectSetString(0,name,OBJPROP_FONT,btnFont);

   ObjectSetString(0,name,OBJPROP_TEXT,text);

   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,DisplayFontSize);

   ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,BorderColor);

   ObjectSetInteger(0,name,OBJPROP_ZORDER,PanelObjectCreateZOrder);

   ObjectSetString(0,name,OBJPROP_TOOLTIP,toolTip);

  }

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

//|                                                                  |

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

bool ObjectExists(string name)

  {

   return ObjectFind(0, name) >= 0;

  }

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

//|                                                                  |

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

void SetObjectWidth(string name,long width,string text=NULL,string toolTip="\n")

  {

   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);

   if(text!=NULL)

      ObjectSetString(0,name,OBJPROP_TEXT,text);

   if(toolTip!="\n")

      ObjectSetString(0,name,OBJPROP_TOOLTIP,toolTip);

  }

//Chart Object Text Setting

void SetObjectText(string name,string content,string toolTip="\n",int iBtnBgColor=-1)

  {

   if(ObjectExists(name))

     {

      string objStr=ObjectGetString(0,name,OBJPROP_TEXT);

      if(StringSubstr(objStr,0,1)==""")

         content="""+content;

      ObjectSetString(0,name,OBJPROP_TEXT,content);



      if(toolTip!="\n")

         ObjectSetString(0,name,OBJPROP_TOOLTIP,toolTip);



      if(iBtnBgColor>-1)

         ObjectSetInteger(0,name,OBJPROP_BGCOLOR,iBtnBgColor);



      //WindowRedraw();

     }

  }

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

//|                                                                  |

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

string GetObjectTextValue(string name)

  {

   string objStr=ObjectGetString(0,name,OBJPROP_TEXT);

   if(StringSubstr(objStr,0,1)==""")

      return StringSubstr(objStr,1);

   return objStr;

  }

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

//|                                                                  |

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

long GetObjectWidth(string name)

  {

   return ObjectGetInteger(0, name, OBJPROP_XSIZE);

  }

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

//|                                                                  |

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

long GetObjectOffsetX(string name)

  {

   return ObjectGetInteger(0, name, OBJPROP_XDISTANCE);

  }

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

//|                                                                  |

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

int OffsetPoints(double price1,double price2)

  {

   double pip=Point();

   double diff=StrToDouble(DoubleToStr(price2,Digits))-StrToDouble(DoubleToStr(price1,Digits));

   return (int)((double)(DoubleToStr(diff,Digits))/pip);

  }

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

//|                                                                  |

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

bool HasNextTimeFrame(ENUM_TIMEFRAMES &nowFrame,bool forwardLong)

  {

   int crtIdx=0;

   int totalSize=ArraySize(allFrames);

   for(int i=0,j=totalSize;i<j;i++)

     {

      if(allFrames[i]==nowFrame)

        {

         crtIdx=i;

         break;

        }

     }

   int targetIdx=(forwardLong) ? crtIdx+1 : crtIdx -1;

   if(targetIdx>=0 && targetIdx<totalSize)

     {

      nowFrame=(ENUM_TIMEFRAMES)allFrames[targetIdx];

      return true;

     }

   return false;

  };

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

//|                                                                  |

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

void UpdatePeriodButtons(datetime crtTime,ENUM_TIMEFRAMES period,string btnBaseId)

  {

   int bShift,offsetPoints,upOffsetPoints,downOffsetPoints,rangPoints;

   double OpenPrice,ClosePrice,HightPrice,LowPrice;



   bShift=iBarShift(Symbol(),period,crtTime);

   OpenPrice=iOpen(Symbol(),period,bShift);

   ClosePrice = iClose(Symbol(), period, bShift);

   HightPrice = iHigh(Symbol(), period, bShift);

   LowPrice=iLow(Symbol(),period,bShift);

   offsetPoints=OffsetPoints(OpenPrice,ClosePrice);

   rangPoints=OffsetPoints(LowPrice,HightPrice);



   if(period==PERIOD_H1)

     {

      currentMinPrice = LowPrice;

      currentMaxPrice = HightPrice;

      if(rangPoints==0)

         currentZoomPercent=1;

      else

         currentZoomPercent=(double)CandleRangeMaxWidth/(double)rangPoints;

     }



   long mWidth=(long)(MathAbs(offsetPoints)*currentZoomPercent);

   upOffsetPoints=OffsetPoints(MathMax(OpenPrice,ClosePrice),HightPrice);

   long upWidth=(long)(MathAbs(upOffsetPoints)*currentZoomPercent);

   downOffsetPoints=OffsetPoints(MathMin(OpenPrice,ClosePrice),LowPrice);

   long downWidth=(long)(MathAbs(downOffsetPoints)*currentZoomPercent);

   

   int spaceOffSet = OffsetPoints(HightPrice, currentMaxPrice);

   long spaceWidth = (long)(MathAbs(spaceOffSet)*currentZoomPercent);



   double iBandsVal[3];

   getIBandsOfPeriod(iBandsVal,period,0);

   int midOffsetPoints=OffsetPoints(lastBid,iBandsVal[1]);

   string toolTips="";

   int trendBgColor=-1;

   if(MathAbs(midOffsetPoints)<iBansMiddlePoints)

     {

      toolTips=StringConcatenate("MID Oscillatory (",midOffsetPoints,")");

      SetObjectWidth(btnBaseId+"Prog",iBansMiddlePoints);

     }

   else

     {

      int diffPoints=0;

      if(midOffsetPoints<0)

        {

         diffPoints=OffsetPoints(lastBid,iBandsVal[2]);

         toolTips=StringConcatenate("MID‘!:",midOffsetPoints," Up Distance:",diffPoints);

         trendBgColor=iBansUpperMiddleColor;

        }



      if(midOffsetPoints>0)

        {

         diffPoints=OffsetPoints(iBandsVal[0],lastBid);

         toolTips=StringConcatenate("MID“!:",midOffsetPoints," Lower Distance:",diffPoints);

         trendBgColor=iBansLowerMiddleColor;

        }



      if(diffPoints>0)

        {

         double maxWidth=MathMax((double)diffPoints,(double)IndicatorBtnWidth);

         double myZoom=(double)diffPoints/(double)maxWidth;

         long targetWidth=(long)(myZoom*IndicatorBtnWidth);

         if(targetWidth<5) targetWidth=5;

         SetObjectWidth(btnBaseId+"Prog",targetWidth);

        }

      if(diffPoints<0)

        {

         trendBgColor=iBansOutOfColor;

         toolTips+=" (Out of iBands Range)";

        }

     }



   if(period==PERIOD_H1)

     {

      bShift=iBarShift(Symbol(),PERIOD_H4,crtTime);

      datetime beginTime=iTime(Symbol(),PERIOD_H4,bShift);

      SetObjectText(btnBaseId+"Prog",StringConcatenate("H1: ",(TimeHour(crtTime)-TimeHour(beginTime))+1,"/4"),toolTips,trendBgColor);

     }

   else if(period==PERIOD_M1)

     {

      SetObjectText(btnBaseId+"Prog",StringConcatenate("M1: ",TimeMinute(crtTime)+1,"/60"),toolTips,trendBgColor);

     }

   else if(period==PERIOD_M5)

     {

      SetObjectText(btnBaseId+"Prog",StringConcatenate("M5: ",(TimeMinute(crtTime)+1)/5+1,"/12"),toolTips,trendBgColor);

     }

   else if(period==PERIOD_M15)

     {

      SetObjectText(btnBaseId+"Prog",StringConcatenate("M15: ",(TimeMinute(crtTime)+1)/15+1,"/4"),toolTips,trendBgColor);

     }

   else if(period==PERIOD_M30)

     {

      SetObjectText(btnBaseId+"Prog",StringConcatenate("M30: ",(TimeMinute(crtTime)+1)/30+1,"/2"),toolTips,trendBgColor);

     }



   SetObjectWidth(btnBaseId+"Up",upWidth,"",StringConcatenate("Distance:",spaceOffSet," Offset:",upOffsetPoints,"pips"));

   string bodyStr=IntegerToString(offsetPoints);

   if(mWidth>50) bodyStr=PeriodStr(period)+": "+bodyStr;

   SetObjectWidth(btnBaseId,mWidth,bodyStr,StringConcatenate("Step Increasement ",inNextStepStr(Symbol(),period)));

   ObjectSetInteger(0,btnBaseId+"Up",OBJPROP_XDISTANCE,spaceWidth+IndicatorBtnWidth);



   long xOffset=GetObjectOffsetX(btnBaseId+"Up")+upWidth;

   ObjectSetInteger(0,btnBaseId,OBJPROP_XDISTANCE,xOffset);



   SetObjectWidth(btnBaseId+"Down",downWidth,"",StringConcatenate("Offset:",downOffsetPoints,"pips"));

   ObjectSetInteger(0,btnBaseId+"Down",OBJPROP_XDISTANCE,xOffset+mWidth);



   ObjectSetInteger(0,btnBaseId,OBJPROP_BGCOLOR,(offsetPoints<0) ? ButtonShadowBackColor:ButtonDefaultBackColor);

  }

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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---