DynFloatPivotM
Download scriptThis tool is designed to provide traders with a visual roadmap of significant price levels on a trading chart. Rather than relying on static numbers, it dynamically calculates several "Pivot" points based on recent market activity, helping users identify potential areas of support and resistance.
How the Logic Works
The script looks back at a specific number of previous candles (defined by the user) to analyze the recent price range. It identifies three primary components for every calculation:
- The High: The highest price reached during that period.
- The Low: The lowest price reached during that period.
- The Pivot: An average of the closing prices from the most recent completed candles.
By combining these three elements, the tool generates a variety of specific levels displayed as lines on your chart:
- Core Pivot Points: The primary line represents a balanced average of the high, low, and pivot price. This serves as a central "equilibrium" marker for the current market segment.
- High and Low Projections (HP & LP): These are calculated to show extended levels based on the relationship between the pivot and the extremes. They help identify where price might face pressure or find a floor.
- Mid-Point Markers: The tool also calculates several "halfway" points (such as the midpoint between the High and Low, or averages between the Pivot and its surrounding projected levels). These are essential for identifying deeper "retest" areas or secondary zones where price may pause or reverse.
Key Benefits for Traders
Because these lines update automatically as new price data comes in, they provide a real-time look at the market's structure. Instead of guessing where the next turning point might be, you can use these dynamic levels to:
- Identify entry and exit zones with greater precision.
- Visualize "buffer zones" where price might react before reaching a major level.
- Better understand the balance between current market momentum and historical extremes.
//+------------------------------------------------------------------+
//| DynFloatPivot.mq4 |
//| Copyright © 2006, Nick A. Zhilin |
//| rebus@dialup.etr.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Nick A. Zhilin"
#property link "rebus@dialup.etr.ru"
//----
extern int IPeriod = 96;
extern string note = "Buff:1P;2HP;3LP;4HL/2;5HP/2;6LP/2;7HLPP/2";
//----
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Sienna //P
#property indicator_color2 Aqua //HP
#property indicator_color3 Red //LP
#property indicator_color4 Gray //HL/2
#property indicator_color5 Teal //HP/2
#property indicator_color6 Maroon //LP/2
#property indicator_color7 Yellow //HLPP/2
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("Float Pivot");
//---- indicators
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexLabel(0, "Pivot");
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexLabel(1, "HP");
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexLabel(2, "LP");
SetIndexStyle(3, DRAW_LINE);
SetIndexBuffer(3, ExtMapBuffer4);
SetIndexLabel(3, "HL/2");
SetIndexStyle(4, DRAW_LINE);
SetIndexBuffer(4, ExtMapBuffer5);
SetIndexLabel(4, "HP/2");
SetIndexStyle(5, DRAW_LINE);
SetIndexBuffer(5, ExtMapBuffer6);
SetIndexLabel(5, "LP/2");
SetIndexStyle(6, DRAW_LINE);
SetIndexBuffer(6, ExtMapBuffer7);
SetIndexLabel(6, "HLPP/4");
//---
IndicatorShortName("DynFloatPivot(" + IPeriod + ")");
//----
// Comment("FloatPivot(" + IPeriod + ")");
//----
return(0);
}
int deinit()
{
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Float Pivot |
//+------------------------------------------------------------------+
int start()
{
int i, counted_bars = IndicatorCounted();
//----
i = Bars - counted_bars - 1;
while(i >= 0)
{
double max = High[Highest(NULL, 0, MODE_HIGH, IPeriod, i)];
double min = Low[Lowest(NULL, 0, MODE_LOW, IPeriod, i)];
double pivot = (Close[i+1] + Close[i+2] + Close[i+3]) / 3;
// Pivot
ExtMapBuffer1[i] = (max + min + pivot) / 3; // HLP/3
// (R1 - Pivot) / 2
ExtMapBuffer2[i] = ((2*(max + min + pivot) / 3 - min) +
(max+min+pivot) / 3) / 2; // HP
// (Pivot - S1) / 2
ExtMapBuffer3[i] = ((max + min + pivot) / 3 +
(2*(max + min + pivot) / 3 - max)) / 2;// LP
ExtMapBuffer4[i] = (max + min) / 2;
ExtMapBuffer5[i] = (ExtMapBuffer1[i]+ExtMapBuffer2[i])/2; //HP/2
ExtMapBuffer6[i] = (ExtMapBuffer1[i]+ExtMapBuffer3[i])/2; //LP/2
ExtMapBuffer7[i] = (max + min + pivot + pivot) / 4; //HLPP/2
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments