I want the indicator to show the weekly pivot lines on the daily chart. As you can see on the attached picture, the indicator builds the pivot lines of seven days instead of five days.
What to do to make the indicator build the pivot and show the pivot of five consecutive days?
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.
Hi,
I need some help with the TD Pivot indicator.
I want the indicator to show the weekly pivot lines on the daily chart. As you can see on the attached picture, the indicator builds the pivot lines of seven days instead of five days.
What to do to make the indicator build the pivot and show the pivot of five consecutive days?
The code is:
//| TD Pivot.mq4 |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 RoyalBlue
#property indicator_color2 OrangeRed
//---- buffers
double high[],
low[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("TD Pivot");
//---- indicators
SetIndexLabel (0,"High");
SetIndexStyle (0,DRAW_LINE);
SetIndexBuffer(0,high);
SetIndexLabel (1,"Low");
SetIndexStyle (1,DRAW_LINE);
SetIndexBuffer(1,low);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
for (int i = Bars-IndicatorCounted(); i >= 0; i--)
{
if(TimeHour(iTime(NULL,0,i)) != 0)
{
high = high;
low = low;
continue;
}
int candlesPerWeek = PERIOD_W1/Period(),
week = MathFloor(i/candlesPerWeek)+1;
double H = iHigh(NULL,PERIOD_W1,week),
L = iLow(NULL,PERIOD_W1,week),
O = iOpen(NULL,PERIOD_W1,week),
C = iClose(NULL,PERIOD_W1,week),
X;
if (C < O) X = H + 2*L + C;
else if (C > O) X = 2*H + L + C;
else if (C ==O) X = H + L + 2*C;
high = 0.5*X - L;
low = 0.5*X - H;
}
//----
return(0);
}
//+------------------------------------------------------------------+