Darma Pivots_v1

Download script
Author: Darma
Darma Pivots_v1

This script is a specialized technical analysis tool designed to automatically calculate and display Pivot Points on your trading charts. Pivot points are essential markers used by traders to identify potential areas of support (where prices might stop falling) and resistance (where prices might stop rising).

Instead of requiring you to perform manual mathematical calculations at the start of every session, this tool automates the process by analyzing historical price data and projecting levels for the current period.

How the Logic Works

The script monitors the market's price action and operates based on several key logical steps:

1. Identifying the New Day/Session The tool continuously scans the time on your chart. When it detects a specific hour and minute (which can be customized in the settings), it treats this as the "start" of a new trading period. At this exact moment, it captures the critical price data from the previous period, specifically the highest price reached, the lowest price reached, the closing price, and the opening price.

2. Dynamic Calculations Once the script identifies the start of a new day, it performs several different types of mathematical calculations simultaneously to generate various levels:

  • Pivot Points (P1, P2, P3, P4): It calculates "central" prices based on the relationship between the previous high and low. Depending on your settings, it can use different variations—some including the closing price or the opening price to provide a more comprehensive average of where the market is balanced.
  • Resistance Levels (R3, R4): These are calculated by projecting how much higher the price might go based on its previous volatility. They represent "ceilings" where sellers often step in.
  • Support Levels (S3, S4): Conversely, these project how far lower the price might drop, representing "floors" where buyers are likely to enter the market.

3. Visualizing the Data The script then draws these calculated levels onto your chart as lines. This allows you to see at a glance where the "battlegrounds" for price are located.

  • If you enable Daily Open, it specifically marks the opening price of the day.
  • By toggling various options (like Sup_Res4 or HLCper3), you can choose exactly which mathematical models you want to see on your screen, allowing you to customize the visual layout to match your specific trading style.

Summary for the User

Essentially, this tool acts as an automated "map maker." It looks at what happened in the past (yesterday or the previous session) and uses those numbers to draw a map of where the price is likely to react today. It removes the need for manual calculation, providing you with clear visual cues for potential trading opportunities based on classic institutional pivot theory.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
Darma Pivots_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                            PIVOT |
//|                                                            Darma |
//|                                              http://darmasdt.com |
//+------------------------------------------------------------------+
#property copyright "Darma"
#property link      "http://groups.yahoo.com/group/indotraders"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red 
#property indicator_color2 Goldenrod
#property indicator_color3 Blue
#property indicator_color4 Black
#property indicator_color5 Green
#property indicator_color6 Green
#property indicator_color7 Green
#property indicator_color8 Green

//---- input parameters
extern int change_day_hour=0;
extern bool HLCCper4=false; 
extern bool HLCper3=false; 
extern bool HLper2=false;
extern bool DailyOpen=true; 
extern bool Sup_Res4=false;
extern bool Sup_Res3=false;

//---- buffers
double Pivot4[];
double Pivot3[];
double Pivot2[];
double Pivot1[];
double Res4[];
double Sup4[];
double Res3[];
double Sup3[];


//---- variables
int limit, cur_day, prev_day, barChangeDay;
double y_c,t_o,y_h,y_l,P4,P3,P2,R4,S4,R3,S3;
double day_high, day_low, dayHprev, dayLprev;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_DASHDOTDOT,1);
   SetIndexBuffer(0,Pivot4);
   SetIndexStyle(1,DRAW_LINE,STYLE_DASHDOTDOT,1);
   SetIndexBuffer(1,Pivot3);
   SetIndexStyle(2,DRAW_LINE,STYLE_DASHDOTDOT,1);
   SetIndexBuffer(2,Pivot2);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(3,Pivot1);
   SetIndexStyle(4,DRAW_LINE,STYLE_DASHDOTDOT,1);
   SetIndexBuffer(4,Res4);
   SetIndexStyle(5,DRAW_LINE,STYLE_DASHDOTDOT,1);
   SetIndexBuffer(5,Sup4);
   SetIndexStyle(6,DRAW_LINE,STYLE_DASHDOTDOT,1);
   SetIndexBuffer(6,Res3);
   SetIndexStyle(7,DRAW_LINE,STYLE_DASHDOTDOT,1);
   SetIndexBuffer(7,Sup3);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   ObjectsRedraw();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

int counted_bars=IndicatorCounted();
if (counted_bars<0) return(-1);
if (counted_bars>0) counted_bars--;
  
limit=Bars-counted_bars;
//---- 
   for(int i=limit; i>=0; i--)
      {
        
        cur_day = TimeDay(Time[i]);
        
        if  (
            TimeHour(Time[i]) == change_day_hour &&
            TimeMinute(Time[i]) == 0
            )
            {
            barChangeDay = i;
            y_c = Close[i+1];
            t_o = Open[i];
            y_h = day_high;
            y_l = day_low;
            
            P4 = (y_h + y_l + y_c + t_o) / 4;
            P3 = (y_h + y_l + y_c) / 3;
            P2 = (y_h + y_l) / 2;
            
            R4 = P4 + (P4 - y_l);
            R3 = P3 + (P3 - y_l);
            
            S4 = P4 + (P4 - y_h);
            S3 = P3 + (P3 - y_h);
            
            day_high = High[i];
            day_low  = Low[i];
            } // if
        
        dayHprev = day_high;
        dayLprev = day_low;
        
        day_high = MathMax(day_high, High[i]);
        day_low = MathMin(day_low, Low[i]);   
        
        if (HLCCper4)
           {
           Pivot4[i]=P4; 
           }
        if (HLCper3)
           {
           Pivot3[i]=P3; 
           }
        if (HLper2)
           {
           Pivot2[i]=P2; 
           }
        if (DailyOpen) 
           {
           Pivot1[i]=t_o; 
           }
        if (Sup_Res4)
           {
           Res4[i]=R4; 
           Sup4[i]=S4;
           }
        if (Sup_Res3) 
           {
           Res3[i]=R3; 
           Sup3[i]=S3;
           }
           
        
      } // for
      
//---- done


   return(0);
  }
//+------------------------------------------------------------------+

Comments