Getting bar's index function?

 

Hi,

I am searching for a function of getting a pointed bar's index. Below is the code of calculating last 4 candles height in pips. I would like to know how to program the same thing only from a certain point, for example (as attached in the image) from the red line in the screen. Thanks for any advice.

Best regards,

sacrif


//+------------------------------------------------------------------+
//|                                                      ulalala.mq4 |
//|                                                          Marijus |
//|                                                sacrif.dangus.org |
//+------------------------------------------------------------------+
#property copyright "Marijus"
#property link      "sacrif.dangus.org"

extern int Kampas=0;
double GBPJPYHl0, GBPJPYHl1, GBPJPYHl2, GBPJPYHl3, GBPJPYHl4;

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----

   // GBP/JPY Hl
   double GBPJPYSpread=MarketInfo("GBPJPYcx",MODE_SPREAD);
   GBPJPYHl0=(iHigh("GBPJPYcx",PERIOD_M1,0)-iLow("GBPJPYcx",PERIOD_M1,0))*100;
   GBPJPYHl1=(iHigh("GBPJPYcx",PERIOD_M1,1)-iLow("GBPJPYcx",PERIOD_M1,1))*100;
   GBPJPYHl2=(iHigh("GBPJPYcx",PERIOD_M1,2)-iLow("GBPJPYcx",PERIOD_M1,2))*100;
   GBPJPYHl3=(iHigh("GBPJPYcx",PERIOD_M1,3)-iLow("GBPJPYcx",PERIOD_M1,3))*100;
   GBPJPYHl4=(iHigh("GBPJPYcx",PERIOD_M1,4)-iLow("GBPJPYcx",PERIOD_M1,4))*100;
   

  // GBPJPY Einamosios žvakės HL
   ObjectCreate("GBPJPYHl0", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("GBPJPYHl0",DoubleToStr(GBPJPYHl0,1),9, "Tahoma", SlateGray);
   ObjectSet("GBPJPYHl0", OBJPROP_CORNER, Kampas);
   ObjectSet("GBPJPYHl0", OBJPROP_XDISTANCE, 170);
   ObjectSet("GBPJPYHl0", OBJPROP_YDISTANCE, 40);

   // GBPJPY -1 žvakės HL
   ObjectCreate("GBPJPYHl1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("GBPJPYHl1",DoubleToStr(GBPJPYHl1,1),9, "Tahoma", SlateGray);
   ObjectSet("GBPJPYHl1", OBJPROP_CORNER, Kampas);
   ObjectSet("GBPJPYHl1", OBJPROP_XDISTANCE, 140);
   ObjectSet("GBPJPYHl1", OBJPROP_YDISTANCE, 40);
   
   // GBPJPY -2 žvakės HL
   ObjectCreate("GBPJPYHl2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("GBPJPYHl2",DoubleToStr(GBPJPYHl2,1),9, "Tahoma", SlateGray);
   ObjectSet("GBPJPYHl2", OBJPROP_CORNER, Kampas);
   ObjectSet("GBPJPYHl2", OBJPROP_XDISTANCE, 110);
   ObjectSet("GBPJPYHl2", OBJPROP_YDISTANCE, 40);
   
   // GBPJPY -3 žvakės HL
   ObjectCreate("GBPJPYHl3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("GBPJPYHl3",DoubleToStr(GBPJPYHl3,1),9, "Tahoma", SlateGray);
   ObjectSet("GBPJPYHl3", OBJPROP_CORNER, Kampas);
   ObjectSet("GBPJPYHl3", OBJPROP_XDISTANCE, 80);
   ObjectSet("GBPJPYHl3", OBJPROP_YDISTANCE, 40);

   // GBPJPY -4 žvakės HL
   ObjectCreate("GBPJPYHl4", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("GBPJPYHl4",DoubleToStr(GBPJPYHl4,1),9, "Tahoma", SlateGray);
   ObjectSet("GBPJPYHl4", OBJPROP_CORNER, Kampas);
   ObjectSet("GBPJPYHl4", OBJPROP_XDISTANCE, 50);
   ObjectSet("GBPJPYHl4", OBJPROP_YDISTANCE, 40);
//----
   return(0);
  }
//+------------------------------------------------------------------+
Reason: