# Which indicator allows me to know when the current candle is 3X or 4X longer than the previous ones?

Someone could help me to discover: Which indicator or oscillator allows me to know when the current candle is 3X or 4X longer than the previous ones?

Thanks a lot

Why do you need an indicator? Just code it.

Until you can state your requirements in concrete terms, it can not be coded. What do you mean by “previous ones?”

Not tested, not compiled, just typed.

```input double multiplier=3;
bool isLong(int length, int iBeg=0){
double mr=0;   for(; length > 0, --length)
mr =MathMax(mr, iHigh(_Symbol, _Period, iBeg+length) - iLow(_Symbol, _Period, iBeg+length) );

return mr * multipler < iHigh(_Symbol, _Period, iBeg) - iLow(_Symbol, _Period, iBeg);
}```

Not tested, not compiled, just typed.

Was that so hard you couldn't even attempt it?

F.Black:

Someone could help me to discover: Which indicator or oscillator allows me to know when the current candle is 3X or 4X longer than the previous ones?

Thanks a lot

Hello

Try this indicator for mt5 , it is not plotting the ratio as it evolves but that is an easy change . The following will post a little dot above or below the bar that meets the criteria you set.

```#property copyright "Read the discussion"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot mark
#property indicator_label1  "mark"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrFuchsia
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3
/*
when do we want an alert for the ratio
*/
more_than=0,//>Ratio limit
less_than=1,//<Ratio limit
more_than_and_equal=2,//>=Ratio limit
less_than_and_equal=3//<=Ratio limit
};
input double theRatio=3.0;//the ratio limit
input int candleOffset=1;//compare with the candle this many positions ago (one candle)
input int arrowCode=108;//arrow code
input int markDistancePoints=200;//mark distance in points
//--- indicator buffers
double         mark[];
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,mark,INDICATOR_DATA);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
PlotIndexSetInteger(0,PLOT_ARROW,arrowCode);
return(INIT_SUCCEEDED);
}
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[],
{
int from=MathMax(0,rates_total-prev_calculated);
for(int i=from;i<rates_total;i++)
{
if(i>candleOffset)
{
//reset the indication
mark[i]=EMPTY_VALUE;
//get the size of the "previous" candle
double previous_candle=high[i-candleOffset]-low[i-candleOffset];
//get the size of this candle
double this_candle=high[i]-low[i];
//the bars must be pointing to the same direction and the bars must have size
if((previous_candle>0.0&&this_candle>0.0)&&((open[i]>close[i]&&open[i-candleOffset]>close[i-candleOffset])||(open[i]<=close[i]&&open[i-candleOffset]<=close[i-candleOffset])))
{
double markprice=low[i]-((double)markDistancePoints)*_Point;
if(open[i]>close[i]){markprice=high[i]+((double)markDistancePoints)*_Point;}
//the ratio is the size of this candle by the size of the previous candle
double ratio=this_candle/previous_candle;
//if the ratio fits our criteria light up the mark
if(ratioMode==more_than&&ratio>theRatio){mark[i]=markprice;}
else if(ratioMode==more_than_and_equal&&ratio>=theRatio){mark[i]=markprice;}
else if(ratioMode==less_than<theRatio){mark[i]=markprice;}
else if(ratioMode==less_than_and_equal<theRatio){mark[i]=markprice;}

}
}
}
return(rates_total);
}
```

William Roeder #:

Why do you need an indicator? Just code it.

Until you can state your requirements in concrete terms, it can not be coded. What do you mean by “previous ones?”

Not tested, not compiled, just typed.

Not tested, not compiled, just typed.

Was that so hard you couldn't even attempt it?

Thank you. I will try to do it checking only the previous candle.
Reason: