^Pivot_PP_v1

Download script
Author: Modest, Rosh conversed only
^Pivot_PP_v1

This tool is designed to automatically identify and display specific price levels on a trading chart, specifically focusing on "Pivot Points" derived from the previous day's market activity. It serves as a visual guide for traders who want to see key historical benchmarks used to determine potential support and resistance areas.

Core Logic and Functionality

1. Timeframe Monitoring The script is designed to operate effectively on shorter timeframes (such as 1-hour or lower). It constantly monitors the passage of time to detect when a new trading day begins. Once a new day starts, it triggers a calculation to establish the price levels for that specific period.

2. Data Collection from the Previous Day To determine where the current day's "Pivot Point" should be, the script analyzes the complete data set of the previous completed trading day. It looks for three key pieces of information:

  • The highest price reached during that day.
  • The lowest price reached during that day.
  • The closing price at the end of that day.

3. Pivot Point Calculation Based on these three values, the script calculates a central "Pivot Point" using two different mathematical approaches (which you can choose between in the settings):

  • Standard Method: A simple average involving the High, Low, and the previous Close.
  • Alternative Method: A weighted average that places more significance on the previous day's closing price.

4. Visual Continuity Rather than showing a single dot or a disconnected line, the script ensures that once a Pivot Point is calculated for a new day, that value remains visible and consistent across all subsequent bars of the current day. This creates a steady horizontal reference level on your chart, allowing you to see exactly where the "center" of the previous day's price action sits relative to the current live market movement.

5. Practical Application By identifying these levels automatically, the tool helps traders quickly spot significant boundaries. When the current price approaches these calculated Pivot Points, it may indicate a zone where the market is likely to react, stall, or reverse, providing a clear visual cue for making informed trading decisions.

Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
^Pivot_PP_v1
//+------------------------------------------------------------------+
//|                                                    ^Pivot_PP.mq4 |
//|                                      Modest, Rosh conversed only |
//|                           http://forexsystems.ru/phpBB/index.php |
//+------------------------------------------------------------------+
#property copyright "Modest, Rosh conversed only"
#property link      "http://forexsystems.ru/phpBB/index.php"
//// Ñòðîèì Pivot è Res/Supp ïî FibonacciTrader Journal Issue 6
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int       Formula=0;
int i=1, shift;
double FP=0.0;
double FH=0.0, FL=0.0;
bool result;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Ïðîâåðêà íîâîãî äíÿ                                              |
//+------------------------------------------------------------------+
bool isNewDay(int _shift)
  {
//---- 
   result=false;
   if((TimeHour(Time[_shift])==0)  && (TimeMinute(Time[_shift])==0)  )result=true;
//----
   return(result);
  }
//+------------------------------------------------------------------+
//| Ïîëó÷èòü óðîâåíü FP ïðîøåäøåãî äíÿ                               |
//+------------------------------------------------------------------+
double GetFPofDay(int _shift)
  {
   int prevDay=TimeDay(Time[_shift+1]);
//---- 
   i=1;
   while(TimeDay(Time[_shift+i])==prevDay) i++;
   i--;
   FH=High[Highest(NULL,0,MODE_HIGH,i,_shift+1)];
   FL=Low[Lowest(NULL,0,MODE_LOW,i,_shift+1)];
   if (Formula==0) FP=NormalizeDouble((FH+FL+Close[_shift+1])/3.0,Digits); else FP=NormalizeDouble((FH+FL+2*Close[_shift+1])/4.0,Digits);
//----
   return(FP);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   if (Formula!=0)Formula=1;
   string label="Pivot_PP("+Formula+")";
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,160);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexLabel(0,label);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit,firstDay;
   int counted_bars=IndicatorCounted();
   if (counted_bars<0) return(0);
   if (counted_bars==0)
     {
      limit=Bars-1;
      i=1;
      firstDay=TimeDay(Time[limit]);
      while(TimeDay(Time[limit-i])==firstDay) i++;
      limit=limit-i-PERIOD_D1/Period();
     }
   if (counted_bars>0) limit=Bars-counted_bars;
//---- 
   if (Period()>PERIOD_H4) return;
   for(shift=limit;shift>=0;shift--)
     {
      if (isNewDay(shift)) ExtMapBuffer1[shift]=GetFPofDay(shift); else  ExtMapBuffer1[shift]=ExtMapBuffer1[shift+1];
      //if (shift==0) SetNullBarValue(shift);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments