//+------------------------------------------------------------------+
//|                                                    Test Indi.mq4 |
//|                                                    abc@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025"
#property link      "https://www.abc.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

//+------------------------------------------------------------------+
// User Input Variables

int      refreshMS=1000;
string   sym=Symbol();
int      tTF=Period();

ENUM_LINE_STYLE VLStyle=3;
bool     VLLabelDel=true;
string   VLLabel="VL_";

int      VLGrWid=1;
color    VLGrClr=clrLime;

int      VLRdWid=1;
color    VLRdClr=clrPink;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit() {

   EventSetMillisecondTimer(refreshMS); // in Milliseconds

   return(INIT_SUCCEEDED);
   }

//+------------------------------------------------------------------+
//| Deinitialization function                                        |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {

   EventKillTimer();
   Comment("");

   for(int i=ObjectsTotal()-1; i>=0; i--) {
   if(VLLabelDel && StringFind(ObjectName(i),VLLabel)!=-1) ObjectDelete(ObjectName(i));}
   }

//+------------------------------------------------------------------+
//| 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 Vertical Lines Main Chart
   for(int i=0; i<=50; i++) {double cSto0=iStochastic(sym,tTF,5,3,3,0,0,0,i);

   if(cSto0<=20) drawVL(i,VLLabel+"Up",VLGrClr,VLGrWid,true);

   if(cSto0>=80) drawVL(i,VLLabel+"Dw",VLRdClr,VLRdWid,true);}
   //+-------------------------------------------+

   return(rates_total);
   }

//+------------------------------------------------------------------+
//| Draw Vertical Lines on Selected Bar Chart                        |
//+------------------------------------------------------------------+
void drawVL(int i, string text, color colour, int width, bool draw) {

   if(draw) {ObjectCreate(text+IntegerToString(Time[i]),OBJ_VLINE,0,Time[i],0);
             ObjectSet(text+IntegerToString(Time[i]),OBJPROP_STYLE,VLStyle);
             ObjectSet(text+IntegerToString(Time[i]),OBJPROP_BACK,true);
             ObjectSet(text+IntegerToString(Time[i]),OBJPROP_COLOR,colour);
             ObjectSet(text+IntegerToString(Time[i]),OBJPROP_WIDTH,width);}
   }

