PivotDyna
Download scriptThis tool is designed to automatically calculate and display "Pivot Points" on your trading chart, which are essential levels used by many traders to identify potential areas of support and resistance. Instead of requiring you to calculate these values manually, the script scans your historical price data to determine key price benchmarks based on specific timeframes.
How the Logic Works
The core functionality of this script revolves around identifying the boundaries of each trading day. Here is a breakdown of the logic in simple steps:
1. Identifying the Daily Transition The script constantly monitors the market clock. Every time it detects the very beginning of a new day (midnight), it triggers a calculation. It looks backward to capture all the price action from the previous day to establish the baseline for the current period.
2. Finding Highs and Lows For every new day, the script automatically searches through the historical data to find two specific numbers:
- The highest price reached during that period.
- The lowest price reached during that period.
3. Calculating the Pivot Point Once it has the "Highest" and "Lowest" prices, the script applies a specific mathematical formula to determine the Pivot Point. It takes these two extremes and combines them with the closing price of the previous session. By averaging these values, it creates a central "balance point" for the market.
4. Real-Time Updating The script performs this calculation twice:
- Historical View: It populates the chart with lines for all past days so you can see where previous support and resistance levels were formed.
- Live View: It calculates a "current" pivot point for the day you are currently trading, ensuring that as the price moves, you have an updated reference point on your screen.
Summary of Purpose
Essentially, this tool removes the guesswork from technical analysis. It automates the process of finding the market's daily "middle ground," allowing you to see significant price levels instantly without having to manually calculate the highs, lows, and closing prices of every preceding day.
//+------------------------------------------------------------------+
//| Äèíàìè÷åñêèé Pivot |
//| ë¸êñóñ - Conversion only |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 White
//---- input parameters
extern int Formula=0;
//---- buffers
double Pivot[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,Pivot);
SetIndexStyle (0,DRAW_SECTION);
SetIndexEmptyValue(0,0.0);
return(0);
}
int deinit() { return(0); }
//+------------------------------------------------------------------+
int start()
{
// Ñòðîèì Pivot è Res/Supp ïî FibonacciTrader Journal Issue 6
int i,shift;
double FP,FH,FL;
// if(Period()>60) return(0);
for(shift=Bars-1; shift>=0; shift--)
{
Pivot[shift]=0;
if (TimeHour(Time[shift])==0 && TimeMinute(Time[shift])==0 ) //íà÷àëî äíÿ
{
i=1;
while(TimeDay(Time[shift+i])==TimeDay(Time[shift+i+1])) { i++; }
FH=High[Highest(NULL,0,MODE_HIGH,i,shift)];
FL= Low[ Lowest(NULL,0,MODE_LOW, i,shift)];
FP=(FH+FL+Close[shift+1+Formula]+Close[shift+1+Formula])/4; //Çíà÷åíèå PivotPoint
Pivot[shift]=FP;
}
if(shift==0)
{
i=1;
while(TimeDay(Time[0])==TimeDay(Time[i])) { i++; }
FH=High[ Highest(NULL,0,MODE_HIGH,i,i)];
FL=Low[ Lowest(NULL,0,MODE_LOW,i,i)];
FP=(FH+FL+Close[0]+Close[0])/4; //Çíà÷åíèå PivotPoint
Pivot[0]=FP;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments