#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Green
#property indicator_color6 Green
#property indicator_color7 Green
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, d;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
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.
Hello All,
This is my Weekly Pivots indicator. Please check the values if you wish use it.
//+------------------------------------------------------------------+
//| Weekly Pivots.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, JYForex."
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Green
#property indicator_color6 Green
#property indicator_color7 Green
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3
#property indicator_width4 3
#property indicator_width5 3
#property indicator_width6 3
#property indicator_width7 3
double weekly_pp[];
double weekly_r1[];
double weekly_r2[];
double weekly_r3[];
double weekly_s1[];
double weekly_s2[];
double weekly_s3[];
void
get_weekly_pivot_points(int index, int wshift)
{
double h, c, l, r;
double pp, r1, r2, r3, s1, s2, s3;
h = iHigh(NULL, PERIOD_W1, wshift);
c = iClose(NULL, PERIOD_W1, wshift);
l = iLow(NULL, PERIOD_W1, wshift);
r = h - l;
pp = (h+l+c)/3;
r1 = (2 * pp) - l;
r2 = pp + r;
r3 = r2 + r;
s1 = (2 * pp) - h;
s2 = pp - r;
s3 = s2 - r;
weekly_pp[index] = pp;
weekly_r1[index] = r1;
weekly_r2[index] = r2;
weekly_r3[index] = r3;
weekly_s1[index] = s1;
weekly_s2[index] = s2;
weekly_s3[index] = s3;
}
int
get_day_shift(int b)
{
int i, r, p;
datetime t, td;
t = Time[b]; // Start time of the bar
td = iTime(Symbol(), PERIOD_W1, 0); // Start of week
r = 1;
for (i = 0; i < 1000; i++) {
if (t >= td) {
return (r);
}
td = iTime(Symbol(), PERIOD_W1, i);
r++;
}
return (r);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE);
SetIndexStyle(5,DRAW_LINE);
SetIndexStyle(7,DRAW_LINE);
SetIndexBuffer(0,weekly_pp);
SetIndexBuffer(1,weekly_r1);
SetIndexBuffer(2,weekly_r2);
SetIndexBuffer(3,weekly_r3);
SetIndexBuffer(4,weekly_s1);
SetIndexBuffer(5,weekly_s2);
SetIndexBuffer(6,weekly_s3);
IndicatorShortName("Weekly Pivots");
SetIndexLabel(0,"Weekly PP");
SetIndexLabel(1,"Weekly R1");
SetIndexLabel(2,"Weekly R2");
SetIndexLabel(3,"Weekly R3");
SetIndexLabel(4,"Weekly S1");
SetIndexLabel(5,"Weekly S2");
SetIndexLabel(6,"Weekly S3");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, d;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i<limit; i++) {
d = get_day_shift(i);
get_weekly_pivot_points(i, d);
}
//----
return(0);
}
//+------------------------------------------------------------------+