Noone can help?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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);
}
//+------------------------------------------------------------------+