Will one of you kind traders turn this code into an indicator?
The Daily Pivot Point Shifted indicator gives the best levels I think but I would also like the mid levels.
On the MQL4 code base site generous Jellybean posted the indicator and someone in the comment section added mid levels to the indicator but only posted the code.
Here's the location:
http://codebase.mql4.com/5207
And here's the code:
//--------------------------------------------------------------------
// Pivot Points - Daily (Shifted) MIDPOINTS.mq4
// Copyright 2009, SwingTree Ltd
//
// This indicator plots horizontal lines at daily pivot levels R3, R2,
// R1, Pivot, S1, S2 & S3, using a day that is advanced (or retarded)
// from the server time (called Pivot Day).
//
// The only input is the integer "ShiftHrs", which gives the number of
// hours to advance the pivot day. A negative value delays the day for
// pivot calculation. For example, if your server is on New York time
// (GMT-5) and you want pivot points in London time (GMT), then
// ShiftHrs is set to +5 (the default in the code).
//
// Saturday and Sunday trading is not ignored (after all it was real
// trading). If the pivot day shift results in data appearing on
// Saturday, it was really Friday where it occured, so the indicator
// treats it as part of Friday. If the pivot day shift results in data
// appearing on Sunday, it was really Monday where it occured, so the
// indicator treats it as Monday.
//
// It uses an indicator buffer for each line, so pivot levels of
// previous days remain visible. (This has a negative consequence:
// it is not possible to use the same technique to draw intermediate
// levels (S0.5, S1.5, etc.) because of the limit of 8 buffers.)
//
// Labels are shown for the most recent day's levels.
//
// This indicator can be applied to any chart period, although daily
// pivots on charts with long periods are meaningless.
//
// 2009.07.02
// There was an error in the calculation of R3 & S3,
// which is now corrected.
//
//--------------------------------------------------------------------
#property copyright "Copyright 2009, SwingTree Ltd"
#define RM3_NAME "Daily RM3"
#define RM2_NAME "Daily RM2"
#define RM1_NAME "Daily RM1"
#define PIVOT_NAME "Daily PP"
#define SM1_NAME "Daily SM1"
#define SM2_NAME "Daily SM2"
#define SM3_NAME "Daily SM3"
#define FONT "Arial"
#define RM3_COL DimGray
#define RM2_COL DimGray
#define RM1_COL DimGray
#define PIVOT_COL White
#define SM1_COL DimGray
#define SM2_COL DimGray
#define SM3_COL DimGray
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 RM3_COL
#property indicator_color2 RM2_COL
#property indicator_color3 RM1_COL
#property indicator_color4 PIVOT_COL
#property indicator_color5 SM1_COL
#property indicator_color6 SM2_COL
#property indicator_color7 SM3_COL
// Input(s)
extern int ShiftHrs = 5; // Pivot day shift
// positive value moves pivot day earlier
// Buffers for levels
double ResM3[], ResM2[], ResM1[], Pivot[], SupM1[], SupM2[], SupM3[];
double PDayHigh, PDayLow;
string ThisSymbol;
datetime BarTime, PivotDayStartTime;
int VisibleBars, DayStartBar, LeftMostBar, RightMostBar;
//--------------------------------------------------------------------
// Initialization
//--------------------------------------------------------------------
int init()
{
// Attach indicator arrays to buffers
SetIndexBuffer( 0, ResM3);
SetIndexBuffer( 1, ResM2);
SetIndexBuffer( 2, ResM1);
SetIndexBuffer( 3, Pivot);
SetIndexBuffer( 4, SupM1);
SetIndexBuffer( 5, SupM2);
SetIndexBuffer( 6, SupM3);
// Set styles
SetIndexStyle( 0, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 1, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 2, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 3, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 4, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 5, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 6, DRAW_LINE, STYLE_DOT, 1);
// Set empty values
SetIndexEmptyValue( 0, EMPTY_VALUE );
SetIndexEmptyValue( 1, EMPTY_VALUE );
SetIndexEmptyValue( 2, EMPTY_VALUE );
SetIndexEmptyValue( 3, EMPTY_VALUE );
SetIndexEmptyValue( 4, EMPTY_VALUE );
SetIndexEmptyValue( 5, EMPTY_VALUE );
SetIndexEmptyValue( 6, EMPTY_VALUE );
// Set labels
SetIndexLabel( 0, RM3_NAME );
SetIndexLabel( 1, RM2_NAME );
SetIndexLabel( 2, RM1_NAME );
SetIndexLabel( 3, PIVOT_NAME );
SetIndexLabel( 4, SM1_NAME );
SetIndexLabel( 5, SM2_NAME );
SetIndexLabel( 6, SM3_NAME );
// Put text on the chart
ObjectCreate( RM3_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( RM2_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( RM1_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( PIVOT_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( SM1_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( SM2_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( SM3_NAME, OBJ_TEXT, 0, 0, 0 );
// Set the text characteristics
ObjectSetText( RM3_NAME, RM3_NAME, 8, FONT, RM3_COL );
ObjectSetText( RM2_NAME, RM2_NAME, 8, FONT, RM2_COL );
ObjectSetText( RM1_NAME, RM1_NAME, 8, FONT, RM1_COL );
ObjectSetText( PIVOT_NAME, PIVOT_NAME, 8, FONT, PIVOT_COL );
ObjectSetText( SM1_NAME, SM1_NAME, 8, FONT, SM1_COL );
ObjectSetText( SM2_NAME, SM2_NAME, 8, FONT, SM2_COL );
ObjectSetText( SM3_NAME, SM3_NAME, 8, FONT, SM3_COL );
// Catch bad input
if( MathAbs( ShiftHrs ) > 23 )
{
Alert( "ShiftHrs is too large. Reset to 0 hrs. ");
ShiftHrs = 0;
}
ThisSymbol = Symbol();
PivotDayStartTime = Time[Bars-1]; // the first bar
return(0);
}
//--------------------------------------------------------------------
//| De-initialization |
//--------------------------------------------------------------------
int deinit()
{
// Remove texts
ObjectDelete( RM3_NAME );
ObjectDelete( RM2_NAME );
ObjectDelete( RM1_NAME );
ObjectDelete( PIVOT_NAME );
ObjectDelete( SM1_NAME );
ObjectDelete( SM2_NAME );
ObjectDelete( SM3_NAME );
return(0);
}
//--------------------------------------------------------------------
//| Main iteration |
//--------------------------------------------------------------------
int start()
{
int i, Count;
double Range;
i = Bars - IndicatorCounted() - 1;
while(i >= 0)
{
// If the pivot day changes...
if( PivotDay( Time[i+1], ShiftHrs ) != PivotDay( Time[i], ShiftHrs ) )
{
// Determine High & Low for the previous Pivot Day
Count = iBarShift( NULL, 0, PivotDayStartTime ) - i; // number of bars in the day
PDayHigh = High[ iHighest( NULL, 0, MODE_HIGH, Count, i+1 ) ]; // Pivot Day high
PDayLow = Low[ iLowest( NULL, 0, MODE_LOW, Count, i+1 ) ]; // Pivot Day low
// Pivot calculations
Pivot[i] = ( PDayHigh + PDayLow + Close[i+1] ) / 3; // Pivot point
Range = PDayHigh - PDayLow; // Range
ResM1[i] = ((2 * Pivot[i] - PDayLow) - (Pivot[i])) /2 + Pivot[i]; // RM1
ResM2[i] = ((Pivot[i] + Range) - (2 * Pivot[i] - PDayLow)) /2 + (2 * Pivot[i] - PDayLow); // RM2
ResM3[i] = ((Pivot[i] + Range *2) - (Pivot[i] + Range)) /2 + (Pivot[i] + Range); // RM3
SupM1[i] = Pivot[i] - ((Pivot[i]) -(2 * Pivot[i] - PDayHigh)) /2 ; // SM1
SupM2[i] = ((2 * Pivot[i] - PDayHigh) - (Pivot[i] - Range)) /2 + (Pivot[i] - Range); // SM2
SupM3[i] = ((Pivot[i] - Range) - (Pivot[i] - Range *2)) /2 + (Pivot[i] - Range *2); // SM3
// Don't draw the transition between levels
ResM3[i+1] = EMPTY_VALUE;
ResM2[i+1] = EMPTY_VALUE;
ResM1[i+1] = EMPTY_VALUE;
Pivot[i+1] = EMPTY_VALUE;
SupM1[i+1] = EMPTY_VALUE;
SupM2[i+1] = EMPTY_VALUE;
SupM3[i+1] = EMPTY_VALUE;
// Remember when the Day changed over
PivotDayStartTime = Time[i];
}
else // no change to pivot levels
{
ResM3[i] = ResM3[i+1];
ResM2[i] = ResM2[i+1];
ResM1[i] = ResM1[i+1];
Pivot[i] = Pivot[i+1];
SupM1[i] = SupM1[i+1];
SupM2[i] = SupM2[i+1];
SupM3[i] = SupM3[i+1];
}
// Move the labels to sensible places
// If this is the last bar and (it's a new bar or time scale has changed)...
if( i == 0 && ( BarTime != Time[i] || VisibleBars != WindowBarsPerChart() ) )
{
DayStartBar = iBarShift( ThisSymbol, Period(), PivotDayStartTime );
LeftMostBar = WindowFirstVisibleBar()-7;
RightMostBar = 15;
if( DayStartBar < RightMostBar ) // label too close to the right
{
ObjectMove( RM3_NAME, 0, Time[RightMostBar], ResM3[i] );
ObjectMove( RM2_NAME, 0, Time[RightMostBar], ResM2[i] );
ObjectMove( RM1_NAME, 0, Time[RightMostBar], ResM1[i] );
ObjectMove( PIVOT_NAME, 0, Time[RightMostBar], Pivot[i] );
ObjectMove( SM1_NAME, 0, Time[RightMostBar], SupM1[i] );
ObjectMove( SM2_NAME, 0, Time[RightMostBar], SupM2[i] );
ObjectMove( SM3_NAME, 0, Time[RightMostBar], SupM3[i] );
}
else if ( DayStartBar > LeftMostBar ) // label too close to the left
{
ObjectMove( RM3_NAME, 0, Time[LeftMostBar], ResM3[i] );
ObjectMove( RM2_NAME, 0, Time[LeftMostBar], ResM2[i] );
ObjectMove( RM1_NAME, 0, Time[LeftMostBar], ResM1[i] );
ObjectMove( PIVOT_NAME, 0, Time[LeftMostBar], Pivot[i] );
ObjectMove( SM1_NAME, 0, Time[LeftMostBar], SupM1[i] );
ObjectMove( SM2_NAME, 0, Time[LeftMostBar], SupM2[i] );
ObjectMove( SM3_NAME, 0, Time[LeftMostBar], SupM3[i] );
}
else // move it with the bars
{
ObjectMove( RM3_NAME, 0, PivotDayStartTime, ResM3[i] );
ObjectMove( RM2_NAME, 0, PivotDayStartTime, ResM2[i] );
ObjectMove( RM1_NAME, 0, PivotDayStartTime, ResM1[i] );
ObjectMove( PIVOT_NAME, 0, PivotDayStartTime, Pivot[i] );
ObjectMove( SM1_NAME, 0, PivotDayStartTime, SupM1[i] );
ObjectMove( SM2_NAME, 0, PivotDayStartTime, SupM2[i] );
ObjectMove( SM3_NAME, 0, PivotDayStartTime, SupM3[i] );
}
}
VisibleBars = WindowBarsPerChart();
BarTime = Time[i];
i--;
}
return(0);
}
//--------------------------------------------------------------------
// int PivotDay( datetime BarTime, datetime ShiftHrs )
// Returns the day of the week for pivot point calculations.
// datetime BarTime: time stamp of the bar of interest
// datetime Shift: the pivot time - server time shift
// i.e. if the time for pivot calculation is ahead
// of server time, the shift is positive.
//--------------------------------------------------------------------
int PivotDay( datetime BarTime, datetime ShiftHrs )
{
int PDay = TimeDayOfWeek( BarTime + ShiftHrs * 3600 );
if( PDay == 0 ) PDay = 1; // Count Sunday as Monday
if( PDay == 6 ) PDay = 5; // Count Saturday as Friday
return( PDay );
}
The Daily Pivot Point Shifted indicator gives the best levels I think but I would also like the mid levels.
On the MQL4 code base site generous Jellybean posted the indicator and someone in the comment section added mid levels to the indicator but only posted the code.
Here's the location:
http://codebase.mql4.com/5207
And here's the code:
//--------------------------------------------------------------------
// Pivot Points - Daily (Shifted) MIDPOINTS.mq4
// Copyright 2009, SwingTree Ltd
//
// This indicator plots horizontal lines at daily pivot levels R3, R2,
// R1, Pivot, S1, S2 & S3, using a day that is advanced (or retarded)
// from the server time (called Pivot Day).
//
// The only input is the integer "ShiftHrs", which gives the number of
// hours to advance the pivot day. A negative value delays the day for
// pivot calculation. For example, if your server is on New York time
// (GMT-5) and you want pivot points in London time (GMT), then
// ShiftHrs is set to +5 (the default in the code).
//
// Saturday and Sunday trading is not ignored (after all it was real
// trading). If the pivot day shift results in data appearing on
// Saturday, it was really Friday where it occured, so the indicator
// treats it as part of Friday. If the pivot day shift results in data
// appearing on Sunday, it was really Monday where it occured, so the
// indicator treats it as Monday.
//
// It uses an indicator buffer for each line, so pivot levels of
// previous days remain visible. (This has a negative consequence:
// it is not possible to use the same technique to draw intermediate
// levels (S0.5, S1.5, etc.) because of the limit of 8 buffers.)
//
// Labels are shown for the most recent day's levels.
//
// This indicator can be applied to any chart period, although daily
// pivots on charts with long periods are meaningless.
//
// 2009.07.02
// There was an error in the calculation of R3 & S3,
// which is now corrected.
//
//--------------------------------------------------------------------
#property copyright "Copyright 2009, SwingTree Ltd"
#define RM3_NAME "Daily RM3"
#define RM2_NAME "Daily RM2"
#define RM1_NAME "Daily RM1"
#define PIVOT_NAME "Daily PP"
#define SM1_NAME "Daily SM1"
#define SM2_NAME "Daily SM2"
#define SM3_NAME "Daily SM3"
#define FONT "Arial"
#define RM3_COL DimGray
#define RM2_COL DimGray
#define RM1_COL DimGray
#define PIVOT_COL White
#define SM1_COL DimGray
#define SM2_COL DimGray
#define SM3_COL DimGray
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 RM3_COL
#property indicator_color2 RM2_COL
#property indicator_color3 RM1_COL
#property indicator_color4 PIVOT_COL
#property indicator_color5 SM1_COL
#property indicator_color6 SM2_COL
#property indicator_color7 SM3_COL
// Input(s)
extern int ShiftHrs = 5; // Pivot day shift
// positive value moves pivot day earlier
// Buffers for levels
double ResM3[], ResM2[], ResM1[], Pivot[], SupM1[], SupM2[], SupM3[];
double PDayHigh, PDayLow;
string ThisSymbol;
datetime BarTime, PivotDayStartTime;
int VisibleBars, DayStartBar, LeftMostBar, RightMostBar;
//--------------------------------------------------------------------
// Initialization
//--------------------------------------------------------------------
int init()
{
// Attach indicator arrays to buffers
SetIndexBuffer( 0, ResM3);
SetIndexBuffer( 1, ResM2);
SetIndexBuffer( 2, ResM1);
SetIndexBuffer( 3, Pivot);
SetIndexBuffer( 4, SupM1);
SetIndexBuffer( 5, SupM2);
SetIndexBuffer( 6, SupM3);
// Set styles
SetIndexStyle( 0, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 1, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 2, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 3, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 4, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 5, DRAW_LINE, STYLE_DOT, 1);
SetIndexStyle( 6, DRAW_LINE, STYLE_DOT, 1);
// Set empty values
SetIndexEmptyValue( 0, EMPTY_VALUE );
SetIndexEmptyValue( 1, EMPTY_VALUE );
SetIndexEmptyValue( 2, EMPTY_VALUE );
SetIndexEmptyValue( 3, EMPTY_VALUE );
SetIndexEmptyValue( 4, EMPTY_VALUE );
SetIndexEmptyValue( 5, EMPTY_VALUE );
SetIndexEmptyValue( 6, EMPTY_VALUE );
// Set labels
SetIndexLabel( 0, RM3_NAME );
SetIndexLabel( 1, RM2_NAME );
SetIndexLabel( 2, RM1_NAME );
SetIndexLabel( 3, PIVOT_NAME );
SetIndexLabel( 4, SM1_NAME );
SetIndexLabel( 5, SM2_NAME );
SetIndexLabel( 6, SM3_NAME );
// Put text on the chart
ObjectCreate( RM3_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( RM2_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( RM1_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( PIVOT_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( SM1_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( SM2_NAME, OBJ_TEXT, 0, 0, 0 );
ObjectCreate( SM3_NAME, OBJ_TEXT, 0, 0, 0 );
// Set the text characteristics
ObjectSetText( RM3_NAME, RM3_NAME, 8, FONT, RM3_COL );
ObjectSetText( RM2_NAME, RM2_NAME, 8, FONT, RM2_COL );
ObjectSetText( RM1_NAME, RM1_NAME, 8, FONT, RM1_COL );
ObjectSetText( PIVOT_NAME, PIVOT_NAME, 8, FONT, PIVOT_COL );
ObjectSetText( SM1_NAME, SM1_NAME, 8, FONT, SM1_COL );
ObjectSetText( SM2_NAME, SM2_NAME, 8, FONT, SM2_COL );
ObjectSetText( SM3_NAME, SM3_NAME, 8, FONT, SM3_COL );
// Catch bad input
if( MathAbs( ShiftHrs ) > 23 )
{
Alert( "ShiftHrs is too large. Reset to 0 hrs. ");
ShiftHrs = 0;
}
ThisSymbol = Symbol();
PivotDayStartTime = Time[Bars-1]; // the first bar
return(0);
}
//--------------------------------------------------------------------
//| De-initialization |
//--------------------------------------------------------------------
int deinit()
{
// Remove texts
ObjectDelete( RM3_NAME );
ObjectDelete( RM2_NAME );
ObjectDelete( RM1_NAME );
ObjectDelete( PIVOT_NAME );
ObjectDelete( SM1_NAME );
ObjectDelete( SM2_NAME );
ObjectDelete( SM3_NAME );
return(0);
}
//--------------------------------------------------------------------
//| Main iteration |
//--------------------------------------------------------------------
int start()
{
int i, Count;
double Range;
i = Bars - IndicatorCounted() - 1;
while(i >= 0)
{
// If the pivot day changes...
if( PivotDay( Time[i+1], ShiftHrs ) != PivotDay( Time[i], ShiftHrs ) )
{
// Determine High & Low for the previous Pivot Day
Count = iBarShift( NULL, 0, PivotDayStartTime ) - i; // number of bars in the day
PDayHigh = High[ iHighest( NULL, 0, MODE_HIGH, Count, i+1 ) ]; // Pivot Day high
PDayLow = Low[ iLowest( NULL, 0, MODE_LOW, Count, i+1 ) ]; // Pivot Day low
// Pivot calculations
Pivot[i] = ( PDayHigh + PDayLow + Close[i+1] ) / 3; // Pivot point
Range = PDayHigh - PDayLow; // Range
ResM1[i] = ((2 * Pivot[i] - PDayLow) - (Pivot[i])) /2 + Pivot[i]; // RM1
ResM2[i] = ((Pivot[i] + Range) - (2 * Pivot[i] - PDayLow)) /2 + (2 * Pivot[i] - PDayLow); // RM2
ResM3[i] = ((Pivot[i] + Range *2) - (Pivot[i] + Range)) /2 + (Pivot[i] + Range); // RM3
SupM1[i] = Pivot[i] - ((Pivot[i]) -(2 * Pivot[i] - PDayHigh)) /2 ; // SM1
SupM2[i] = ((2 * Pivot[i] - PDayHigh) - (Pivot[i] - Range)) /2 + (Pivot[i] - Range); // SM2
SupM3[i] = ((Pivot[i] - Range) - (Pivot[i] - Range *2)) /2 + (Pivot[i] - Range *2); // SM3
// Don't draw the transition between levels
ResM3[i+1] = EMPTY_VALUE;
ResM2[i+1] = EMPTY_VALUE;
ResM1[i+1] = EMPTY_VALUE;
Pivot[i+1] = EMPTY_VALUE;
SupM1[i+1] = EMPTY_VALUE;
SupM2[i+1] = EMPTY_VALUE;
SupM3[i+1] = EMPTY_VALUE;
// Remember when the Day changed over
PivotDayStartTime = Time[i];
}
else // no change to pivot levels
{
ResM3[i] = ResM3[i+1];
ResM2[i] = ResM2[i+1];
ResM1[i] = ResM1[i+1];
Pivot[i] = Pivot[i+1];
SupM1[i] = SupM1[i+1];
SupM2[i] = SupM2[i+1];
SupM3[i] = SupM3[i+1];
}
// Move the labels to sensible places
// If this is the last bar and (it's a new bar or time scale has changed)...
if( i == 0 && ( BarTime != Time[i] || VisibleBars != WindowBarsPerChart() ) )
{
DayStartBar = iBarShift( ThisSymbol, Period(), PivotDayStartTime );
LeftMostBar = WindowFirstVisibleBar()-7;
RightMostBar = 15;
if( DayStartBar < RightMostBar ) // label too close to the right
{
ObjectMove( RM3_NAME, 0, Time[RightMostBar], ResM3[i] );
ObjectMove( RM2_NAME, 0, Time[RightMostBar], ResM2[i] );
ObjectMove( RM1_NAME, 0, Time[RightMostBar], ResM1[i] );
ObjectMove( PIVOT_NAME, 0, Time[RightMostBar], Pivot[i] );
ObjectMove( SM1_NAME, 0, Time[RightMostBar], SupM1[i] );
ObjectMove( SM2_NAME, 0, Time[RightMostBar], SupM2[i] );
ObjectMove( SM3_NAME, 0, Time[RightMostBar], SupM3[i] );
}
else if ( DayStartBar > LeftMostBar ) // label too close to the left
{
ObjectMove( RM3_NAME, 0, Time[LeftMostBar], ResM3[i] );
ObjectMove( RM2_NAME, 0, Time[LeftMostBar], ResM2[i] );
ObjectMove( RM1_NAME, 0, Time[LeftMostBar], ResM1[i] );
ObjectMove( PIVOT_NAME, 0, Time[LeftMostBar], Pivot[i] );
ObjectMove( SM1_NAME, 0, Time[LeftMostBar], SupM1[i] );
ObjectMove( SM2_NAME, 0, Time[LeftMostBar], SupM2[i] );
ObjectMove( SM3_NAME, 0, Time[LeftMostBar], SupM3[i] );
}
else // move it with the bars
{
ObjectMove( RM3_NAME, 0, PivotDayStartTime, ResM3[i] );
ObjectMove( RM2_NAME, 0, PivotDayStartTime, ResM2[i] );
ObjectMove( RM1_NAME, 0, PivotDayStartTime, ResM1[i] );
ObjectMove( PIVOT_NAME, 0, PivotDayStartTime, Pivot[i] );
ObjectMove( SM1_NAME, 0, PivotDayStartTime, SupM1[i] );
ObjectMove( SM2_NAME, 0, PivotDayStartTime, SupM2[i] );
ObjectMove( SM3_NAME, 0, PivotDayStartTime, SupM3[i] );
}
}
VisibleBars = WindowBarsPerChart();
BarTime = Time[i];
i--;
}
return(0);
}
//--------------------------------------------------------------------
// int PivotDay( datetime BarTime, datetime ShiftHrs )
// Returns the day of the week for pivot point calculations.
// datetime BarTime: time stamp of the bar of interest
// datetime Shift: the pivot time - server time shift
// i.e. if the time for pivot calculation is ahead
// of server time, the shift is positive.
//--------------------------------------------------------------------
int PivotDay( datetime BarTime, datetime ShiftHrs )
{
int PDay = TimeDayOfWeek( BarTime + ShiftHrs * 3600 );
if( PDay == 0 ) PDay = 1; // Count Sunday as Monday
if( PDay == 6 ) PDay = 5; // Count Saturday as Friday
return( PDay );
}