//+------------------------------------------------------------------+//| PivotHighLowIndicator.mq4 |//| Copyright 2018, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2018, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#property strict#property indicator_chart_window#property indicator_buffers3#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 Blue
double highs[];
double lows [];
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0,highs);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0, 159);
SetIndexBuffer(1,lows);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1, 159);
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//---int limit = rates_total-prev_calculated;
for(int i=1;limit;i++)
{
if (High[i+1]>High[i]
&& High[i+1]>High[i+2])
{
highs[i+1]=High[i+1];
}
if (Low[i+1]<Low[i]
&&Low[i+1]<Low[i+2])
lows[i+1]=Low[i+1];
}
//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+
Above is code for an indicator that works similar to the fractals concept.
1. The indicator plots a shape above any candle who's high is higher than the following and preceding high. If a candle meets these criteria, the high point is identified as a 'first order pivot high'.
2. I would like to add a secondary function to my code that compares each first order pivot high as follows:
Plot a shape above any first order pivot high that is higher than the following and preceding first order pivot highs. If a candle meets these criteria, the high point is identified as a 'second order pivot high'.
I have managed to do the first stage, but I can't figure out how to implement the secondary stage. Appreciate any advice.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Above is code for an indicator that works similar to the fractals concept.
1. The indicator plots a shape above any candle who's high is higher than the following and preceding high. If a candle meets these criteria, the high point is identified as a 'first order pivot high'.
2. I would like to add a secondary function to my code that compares each first order pivot high as follows:
Plot a shape above any first order pivot high that is higher than the following and preceding first order pivot highs. If a candle meets these criteria, the high point is identified as a 'second order pivot high'.
I have managed to do the first stage, but I can't figure out how to implement the secondary stage. Appreciate any advice.