[i] ACD_3

This script is designed to provide traders with a visual representation of price levels based on historical data, specifically utilizing a "Three Day Rolling Pivot" logic. Instead of looking at just the previous day's price action, this tool aggregates data over a specific rolling window to help identify potential support and resistance zones.

How the Logic Works

1. Data Collection Window The script identifies a specific range of time within the trading history. It monitors the market price to find the highest point (High), the lowest point (Low), and the closing price (Close) over a three-day period. By capturing these three specific data points, the script establishes a comprehensive "range" of recent market activity.

2. Pivot Point Calculation Once the high, low, and closing prices for the specified range are identified, the script calculates a central equilibrium point known as the Pivot Point. This is achieved by taking the mathematical average of those three values. This point represents the "balance" of the recent price movement.

3. Dynamic Range Projection (Top and Bottom) Beyond just providing a single center line, the script calculates a secondary range to show market volatility:

  • It determines the midpoint between the high and low prices.
  • It measures the distance (the difference) between that midpoint and the calculated Pivot Point.
  • It then projects this distance equally above and below the Pivot Point to create a Pivot Range Top and a Pivot Range Bottom.

Visual Representation on the Chart

The script translates these calculations into three distinct visual elements on your trading chart:

  • The Pivot Point: A central reference line (represented as a dotted line) showing the primary balance level.
  • The Pivot Range Top: A dashed line showing the upper boundary of the calculated volatility zone.
  • The Pivot Range Bottom: A dashed line showing the lower boundary of the calculated volatility zone.

Summary for Traders

Essentially, this tool takes three days of market history and "compresses" that information into a visible price zone on your current chart. It allows you to see where the market has historically balanced itself over the last few days, providing a clearer picture of potential areas where price might encounter resistance (the top) or support (the bottom).

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
[i] ACD_3
/**
* ACD_3.mq4
* Three Day Rolling Pivot
**/

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green 
#property indicator_color2 DodgerBlue
#property indicator_color3 DodgerBlue

//Input Params
extern string PivotRangeStart = "00:00";
extern string PivotRangeEnd = "00:00";
extern bool DisplayPivotPoint = false;

double Buffer1[];
double Buffer2[];
double Buffer3[];

double pivotRangeHigh;
double pivotRangeLow;
double pivotRangeClose;
double pivotTop=0;
double pivotBottom=0;
    
int init()
{
   SetIndexStyle(0,DRAW_LINE, STYLE_DOT, 1);
   SetIndexBuffer(0,Buffer1);
   SetIndexLabel(0,"Pivot Point");

   SetIndexStyle(1,DRAW_LINE, STYLE_DASH, 1);
   SetIndexBuffer(1,Buffer2);
   SetIndexLabel(1,"Pivot Range Top");

   SetIndexStyle(2,DRAW_LINE, STYLE_DASH, 1);
   SetIndexBuffer(2,Buffer3);
   SetIndexLabel(2,"Pivot Range Bottom");

   return(0);
}

int deinit()
{
   return(0);
}

int start()
{   
   string barTime="", lastBarTime="";    
   string barDay="", lastBarDay="";        
   int openBars[3], tempBars[3];
   int openBar, closeBar;
          
   for(int i=Bars; i>=0; i--)
   {  
      barTime = TimeToStr(Time[i], TIME_MINUTES);
      lastBarTime = TimeToStr(Time[i+1], TIME_MINUTES); 
      barDay = TimeToStr(Time[i],TIME_DATE);
      lastBarDay = TimeToStr(Time[i+1],TIME_DATE);
      
      if ((PivotRangeEnd == "00:00" && barTime>=PivotRangeEnd && barDay>lastBarDay) || (barTime>=PivotRangeEnd && lastBarTime<PivotRangeEnd))     
      {  
         closeBar = i + 1;
         openBar = openBars[2];
         
         ArrayCopy(tempBars, openBars, 1, 0, 2);
         ArrayCopy(openBars, tempBars);
         
         if (openBar>0)
         {
            calculatePivotRangeValues(openBar, closeBar);
         }
      }
      
      if ((PivotRangeStart == "00:00" && barTime>=PivotRangeStart && barDay>lastBarDay) || (barTime>=PivotRangeStart && lastBarTime<PivotRangeStart))
      {
          openBars[0] = i;
      }
      
      if (openBar>0)
      {
          drawIndicators(i);
      }     
   }
   return(0);
}

void calculatePivotRangeValues(int openBar, int closeBar)
{
   pivotRangeHigh = High[Highest(NULL, 0, MODE_HIGH, (openBar - closeBar + 1), closeBar)];
   pivotRangeLow = Low[Lowest(NULL, 0, MODE_LOW, (openBar - closeBar + 1), closeBar)];
   pivotRangeClose = Close[closeBar];
}

void drawIndicators(int curBar)
{
   double pivotPoint, pivotDiff;
   
   if (pivotRangeHigh<=0 || pivotRangeLow <=0 || pivotRangeClose <= 0)
   {
      return(0);
   }
   
   pivotPoint=(pivotRangeHigh + pivotRangeLow + pivotRangeClose)/3;
   pivotDiff = MathAbs(((pivotRangeHigh + pivotRangeLow)/2) - pivotPoint);
   pivotTop = pivotPoint + pivotDiff;
   pivotBottom = pivotPoint - pivotDiff;   

   if (DisplayPivotPoint) Buffer1[curBar]=pivotPoint;
   Buffer2[curBar]=pivotTop;
   Buffer3[curBar]=pivotBottom;
}

Comments