mql4 return last low if lowest

 

Hi

I am just starting with mql4 and playing around with the code, trying to print the low of the bar but only if it is a lower than the lowest value in the current bar.

Any idea what my code is not working? Thanks

The following code is

#property indicator_chart_window
#property indicator_buffers 1
//---- plot Line
#property indicator_label1  "Line"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrYellow
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         LineBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,LineBuffer,INDICATOR_DATA);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//--- Get the number of bars available for the current symbol and chart period
   int bars=Bars(Symbol(),0);
      double currentLow = low[0];
      Print ("Low " , currentLow, " Last low ", prev_calculated); //prev_calculated should have the last "currentLow"?
      return (currentLow);

  }
 
samjesse:

Hi

I am just starting with mql4 and playing around with the code, trying to print the low of the bar but only if it is a lower than the lowest value in the current bar.

Any idea what my code is not working? Thanks

The following code is

Low[0]<Low[1];
 
Mohamad Zulhairi Baba:
Isn't
Low[0]<Low[1];

return true if the current bar low is lower than the previous bar low? if Yes, I am after a new low in the CURRENT bar not the previous one, that is a new low in Bar[0] during its formation.

 
samjesse:
Isn't

return true if the current bar low is lower than the previous bar low? if Yes, I am after a new low in the CURRENT bar not the previous one, that is a new low in Bar[0] during its formation.

something like.

double LLprice = min(Low[0],Low[1]);
Print ("Range low ",LLprice);

or use iHighest, iLowest..