Help requested with getting the bar index number of a specific bar

 

Hi everyone,


I have an indicator that uses the lowest low in a range, the indicator works, but I want to eliminate some falls signals. To do that I need code that calculates the index number of the bar that forms the lowest low in a defined range.

I looked at iBarShift, but that doesn't produce the bar index number of the specific bar.

Can anyone please tell me what that code is if it exists?

 
ReactoFX:

Hi everyone,


I have an indicator that uses the lowest low in a range, the indicator works, but I want to eliminate some falls signals. To do that I need code that calculates the index number of the bar that forms the lowest low in a defined range.

I looked at iBarShift, but that doesn't produce the bar index number of the specific bar.

Can anyone please tell me what that code is if it exists?

MT4 or MT5?
 

MT4

 
ReactoFX:

MT4

iLowest() 

iLowest - Timeseries and Indicators Access - MQL4 Reference
iLowest - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
iLowest - Timeseries and Indicators Access - MQL4 Reference
 
Thanks!
 

It seems I cannot get it to work properly jet, can anyone tell me what I'm doing wrong here?


The condition I want to ad is that the lowest low in a range to the left from the current bar is below the lower envelope calculated on the bar with the lowest low. In this case the range is called Bars.

The indicator works, but this condition is ignored.


   //--- main loop
  

int       LLbar =  iLowest(NULL,0, MODE_LOW,  BarsInCorrection, 0);

  
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(Max_Number_Bars_Back-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation  

      //Indicator Buffer 1
      if(iMA(NULL, 0, MainTrend, 0, MODE_EMA, PRICE_CLOSE, 2+i) < iMA(NULL, 0, MainTrend, 0, MODE_EMA, PRICE_CLOSE, 1+i) //Main Trend is up
      && iHigh(NULL, PERIOD_M15, i) >= Low[iLowest(NULL, PERIOD_M15,MODE_HIGH,BarsInCorrection,i)]+AlertPipRange1_A*Point*10 //Current bid is above the last low plus xx pips
      && iHigh(NULL, PERIOD_M15, i) <= Low[iLowest(NULL, PERIOD_M15,MODE_HIGH,BarsInCorrection,i)]+AlertPipRange1_B*Point*10 //Current bid is below the last low plus xx pips
      && Low[LLbar+i] < iEnvelopes(NULL, 0, 21, MODE_EMA, 0, PRICE_CLOSE, Deviation * 0.1, MODE_LOWER, LLbar+i) // The lowest low < lower envelope at the bar with the lowest low in the range
      )
        {
         Buffer1[i] = Low[iLowest(NULL, PERIOD_M15,MODE_HIGH,BarsInCorrection,i)]+AlertPipRange1_A*Point*10; //Set indicator at value of xx pips from lowest low in period Bars In Correction

         if (AlertsOn = true && i == 0 && Time[0] != time_alert) myAlert("Correction");  //Instant alert once per bar
         time_alert = Time[0];
        }
 
ReactoFX: In this case the range is called Bars.
int      LLbar =  iLowest(NULL,0, MODE_LOW,  Bars, 0);
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it

  2. It can't be called Bars because that is one of the Predefined Variables - MQL4 Reference