DeMarker Pivots_v2

Download script
Author: 2005 Free software for trader
DeMarker Pivots_v2

This script is designed to provide visual technical analysis by automatically calculating and plotting the DeMark Pivot Points on your trading charts. These pivots are essential tools for traders who use price action history to identify potential areas of support and resistance for the current day.

How the Logic Works

The core functionality of this tool relies on analyzing historical daily price data to project levels for the current trading session. Here is a breakdown of how it processes that information:

1. Data Gathering The script first looks back at the previous completed trading day. It specifically identifies three key pieces of information from that day's performance:

  • The Highest Price reached (High)
  • The Lowest Price reached (Low)
  • The Closing Price at the end of the session (Close)

2. The Pivot Point Calculation Using those three figures, the script calculates the central "Pivot" point. This represents the equilibrium price for the current day. If the price stays above this pivot, the sentiment is generally considered bullish; if it stays below, it is often viewed as bearish.

3. Support and Resistance Projection Once the central Pivot is established, the script uses mathematical formulas to project four additional levels onto your chart:

  • Resistance Levels (R1 and R2): These represent "ceilings" where the price may face selling pressure or struggle to break through.
  • Support Levels (S1 and S2): These represent "floors" where the price may find buyers or experience a bounce.

4. Visual Execution The script automatically scans your chart's timeline. Every time it detects a new day starting, it recalculates these values based on the preceding day’s data. It then draws horizontal lines across the chart for:

  • The Main Pivot
  • Resistance 1 (R1)
  • Support 1 (S1)
  • Resistance 2 (R2)
  • Support 2 (S2)

Summary for the Trader

In simple terms, this tool removes the manual math from your workflow. Instead of you having to calculate these levels every morning, the script automatically "draws the map" for the day based on yesterday's price movement, allowing you to see instantly where the most significant price boundaries are likely to be.

Miscellaneous
Implements a curve of type %1
21 Views
0 Downloads
0 Favorites
DeMarker Pivots_v2
//+------------------------------------------------------------------+
//|                                              DeMarker Pivots.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
//---- 
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()
  {
// Pivot
   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