Use ilowest, ihighest

 

Hi friends,

can you help me to modifiy this code with ilowest or ihighest instead of Mathmin or Mathmax.

#property indicator_chart_window
#property indicator_buffers 2

#property indicator_color1 Red
#property indicator_color2 Blue

extern int MA_Shift=0;
extern int MA_Shift1=0;

double L2[];
double H2[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int    draw_begin;
   string short_name;
//---- drawing settings

  IndicatorBuffers(2); 
   SetIndexStyle(0,DRAW_LINE);
   SetIndexShift(0,MA_Shift);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexShift(1,MA_Shift1);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));


//---- indicator short name

   SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
      SetIndexBuffer(0,L2);
      SetIndexBuffer(1,H2);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {

   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;   

   int    i,pos=Bars-ExtCountedBars-1;

   while(pos>=0)
     {

      L2[pos]=MathMin(Low[pos],Low[pos+1]);

     
      H2[pos]=MathMax(MathMax(High[pos],High[pos+1]),High[pos+2]);


           pos--;
     }
     
     }

exactly i want to code something like this:

L2[pos]=ilowest(.....)

H2[pos]=ihighest(....)

etc.

My goal is to develope this code for a custom Period of bars. for example L2[pos]= lowest low price of last n bars.

 
hmrt135:

exactly i want to code something like this:

L2[pos]=ilowest(.....)

H2[pos]=ihighest(....)

So what's stopping you? No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
 
 
deVries
:

https://www.mql5.com/en/code/7107

or https://www.mql5.com/en/code/10401


thank you,

i have earlier saw these pages, but i do not know realy how to can i modify the below code.

double val=Low[iLowest(NULL,0,MODE_LOW,10,10)];

I made earlier the below code, but it does not give me what i asked in the topic:

int i,pos=Bars-ExtCountedBars-1;
if(pos<MA_Period) pos=MA_Period;
for(i=1;i<MA_Period;i++,pos--)
ExtMapBuffer[pos]=Low[iLowest(NULL,0,MODE_LOW,pos,0)];


 

iLowest

Sample:

// calculating the lowest value on the 10 consequtive bars in the range
// from the 10th to the 19th index inclusive on the current chart
double val=Low[iLowest(NULL,0,MODE_LOW,10,10)];


 
int i,pos=Bars-ExtCountedBars-1;
if(pos<MA_Period) pos=MA_Period;
for(i=1;i<MA_Period;i++,pos--)
ExtMapBuffer[pos]=Low[iLowest(NULL,0,MODE_LOW,pos,0)];
Try
ExtCountedBars=IndicatorCounted();
if(ExtCountedBars<MA_Period) ExtCountedBars=MA_Period;
for(iPos=Bars-ExtCountedBars-1; iPos >= 0; iPos--){
    int    iLL = Lowest(NULL,0,MODE_LOW,MA_Period,iPos);
    double pLL = Low[iLL];
    ExtMapBuffer[iPos]=pLL;
}
Then understand the reason why the first doesn't work.
 
WHRoeder:
TryThen understand the reason why the first doesn't work.


thanks,

i have used this code and it works.

   while(pos>=0)
     {
ExtMapBuffer[pos]=Low[iLowest(NULL,0,MODE_LOW,MA_Period,pos)];
           pos--;
     }
Reason: