DeMarker_Pivots

Download script
Author: 2005 Free software for trader
DeMarker_Pivots

This tool is designed to provide traders with a clear visual guide of key price levels on their trading charts. It specifically calculates and displays "Pivot Points," which are standard technical analysis markers used to identify potential areas of support (where prices may stop falling) and resistance (where prices may struggle to rise further).

How the Logic Works

The script functions by analyzing historical data from previous trading sessions to predict key levels for the current day. It follows a structured mathematical process:

1. Data Gathering The tool automatically looks back at the previous day's performance. It identifies three specific price points from that completed session:

  • The highest price reached (High).
  • The lowest price reached (Low).
  • The final price at the end of the session (Close).

2. Pivot Point Calculation Once it has those three numbers, the script calculates the "Main Pivot." This is essentially the average price of the previous day. It serves as the central anchor for all other levels on your chart.

3. Support and Resistance Mapping Using that Main Pivot as a base, the script then generates four additional levels:

  • Primary Levels (R1 & S1): These are the immediate zones above and below the pivot. They are calculated by projecting the difference between the pivot and the previous day's highs/lows.
  • Secondary Levels (R2 & S2): These represent more extended zones. The script calculates these based on the relationship between the primary levels and the main pivot, providing a broader "map" of where the market might react if it breaks through the first layer of resistance or support.

Visual Representation

Instead of just giving you a list of numbers, the script automatically draws these levels as continuous lines on your chart. As each new day begins, the tool recognizes the date change and updates all lines to reflect the new calculations based on the most recent completed day.

This allows you to see at a glance where the "battlegrounds" are for the current trading session, helping you identify potential turning points in price action without having to perform the manual math yourself.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
DeMarker_Pivots
//+------------------------------------------------------------------+
//| DialyPivot.mq4                                                   |
//| These are the main pivots used by Thomas DeMark                  |
//| Written by: Ice                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "2005 Free software for trader"
//----
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_color5 Lime
//---- input parameters
datetime BT[];
double YesterdayHigh[50];
double YesterdayLow[50];
double YesterdayClose[50];
//---- buffers
double PivotArray[];
double R1Array[];
double S1Array[];
double R2Array[];
double S2Array[];
double R3Array[];
double S3Array[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,PivotArray);
IndicatorShortName("TDPivot");
SetIndexLabel(0,"Pivot");
// Resistance 1
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,R1Array);
SetIndexLabel(1,"R1");
// Support 1
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,S1Array);
SetIndexLabel(2,"R1");
// Resistance 2
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,R2Array);
SetIndexLabel(3,"R2");
// Support 2
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,S2Array);
SetIndexLabel(4,"S2");
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
 return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
ArrayResize(BT, Bars); Print("Bars = " + Bars);
// Fill BT with bar open TIME
ArrayCopySeries(BT, MODE_TIME);
// Fill temp arrays with High, Low and Close prices per day
ArrayCopySeries(YesterdayHigh, MODE_HIGH, Symbol(), PERIOD_D1);
ArrayCopySeries(YesterdayLow, MODE_LOW, Symbol(), PERIOD_D1);
ArrayCopySeries(YesterdayClose, MODE_CLOSE, Symbol(), PERIOD_D1);
//----
int od = 0;
int dd = 0;
double Pivot;
double R1; 
double S1;
double R2;
double S2;
//Cycle through all the bars and fill the indicator bars with the Pivot point values
for (int i = 0; i <= Bars; i++) 
{
if (TimeDay(BT[i]) != od) 
{
dd++;
Pivot = (YesterdayHigh[dd] + YesterdayLow[dd] + YesterdayClose[dd])/3;
R1 = (2*Pivot)-YesterdayLow[dd]; 
S1 = (2*Pivot)-YesterdayHigh[dd];
R2 = Pivot-S1+R1;
S2 = Pivot-R1+S1; 
od = TimeDay(BT[i]);
}
PivotArray[i] = Pivot; 
R1Array[i]=R1;
S1Array[i]=S1;
R2Array[i]=R2;
S2Array[i]=S2;
}
//----
return(0);
}
//+------------------------------------------------------------------+

Comments