Floor_Pivots_Minutes

Download script
Floor_Pivots_Minutes

This script is designed to automatically identify and display specific price levels on your trading chart, known as "Pivot Points." These levels act as technical benchmarks that traders use to gauge the potential range of price movement within a specific timeframe.

Core Functionality

The primary purpose of this tool is to calculate seven key price levels based on historical data: one central Pivot Point (P), three Resistance levels (R1, R2, R3), and three Support levels (S1, S2, S3). By identifying these boundaries, the script helps visualise where the market might face pressure or find stability.

How the Logic Works

The script operates through a systematic process to determine these values:

  • Timeframe Synchronization: The tool looks back at a specific set timeframe (defined by the user, such as 240 minutes). It calculates "anchor points" in time to ensure that the data it uses is consistent and synchronized with your current chart view.
  • Data Identification: For every period, the script scans the price history to find the highest price reached (High) and the lowest price reached (Low), along with the closing price.
  • The Pivot Calculation: It calculates the central Pivot Point by taking the average of the previous period's High, Low, and Closing prices. This "middle" value serves as the base for all other calculations.
  • Support and Resistance Mapping:
    • Resistance Levels (R1-R3): These are calculated by adding a multiple of the price range (High minus Low) to the Pivot Point. They represent "ceilings" where selling pressure might increase.
    • Support Levels (S1-S2, S3): These are calculated by subtracting multiples of that same price range from the Pivot Point. They represent "floors" where buying interest might emerge.
  • Visual Displacement: To keep the chart clean and readable, the script can automatically shift these lines forward or backward depending on your settings. This ensures that the levels align correctly with the current candles you are viewing.

User Experience

Instead of you having to manually calculate complex formulas for every session, this script handles the math in the background. It automatically draws a series of horizontal lines across your chart, providing a clear visual map of the "playing field" for the day or session ahead. This allows you to see at a glance where the market's boundaries currently sit based on previous price action.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Floor_Pivots_Minutes
//+------------------------------------------------------------------+
//|                                          Floor_Pivot_Minutes.mq4 |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Silver
#property indicator_color2 Gray
#property indicator_color3 Gray
#property indicator_color4 Gray
#property indicator_color5 Gray
#property indicator_color6 Gray
#property indicator_color7 Gray  // DarkSlateGray
//---- input parameters
extern int T_F   = 240;
extern int limit = 30;
extern int lm    = 0;
//---- buffers
double R3Buffer[];
double R2Buffer[];
double R1Buffer[];
double PBuffer[];
double S1Buffer[];
double S2Buffer[];
double S3Buffer[];


//----
int Displacement;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(7);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,PBuffer);

   SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
   SetIndexStyle(2,DRAW_LINE,STYLE_DOT); 
   SetIndexStyle(3,DRAW_LINE,STYLE_DOT);
   SetIndexStyle(4,DRAW_LINE,STYLE_DOT); 
   SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
   SetIndexStyle(6,DRAW_LINE,STYLE_DOT);       
   SetIndexBuffer(1,R1Buffer);   
   SetIndexBuffer(2,R2Buffer);
   SetIndexBuffer(3,R3Buffer);   
   SetIndexBuffer(4,S1Buffer);
   SetIndexBuffer(5,S2Buffer);   
   SetIndexBuffer(6,S3Buffer);
      
   if( lm==0)
         Displacement=T_F/Period();
      else
         Displacement=1;

SetIndexShift(0,Displacement);
SetIndexShift(1,Displacement);
SetIndexShift(2,Displacement);
SetIndexShift(3,Displacement);
SetIndexShift(4,Displacement);
SetIndexShift(5,Displacement);
SetIndexShift(6,Displacement);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int cb,sbb_index,sbb_Aux_i,sbe_Aux_i,i;
   int counted_bars=IndicatorCounted();
   datetime Corresp_bbbnTime;
   double StHigh,StLow,DHigh,DLow,SStaticStep,SDBStep;
 
   for(cb=limit;cb>=0;cb--)
   {
      Corresp_bbbnTime=NormTimeBarBegin(Time[cb],T_F);
      sbb_index=n_iBarShift(Corresp_bbbnTime,Period());
      
      StHigh=High[iHighest(NULL,0,MODE_HIGH,sbb_index-cb+1,cb)];
      StLow=Low[iLowest(NULL,0,MODE_LOW,sbb_index-cb+1,cb)];
      
      PBuffer[cb]=MathRound((Close[cb]+StHigh+StLow)/3/Point)*Point;

      if( cb<sbb_index )
      {
         for(i=cb+1;i<=sbb_index;i++)
         {
            PBuffer[i]=PBuffer[cb];
            R1Buffer[i]=(2*PBuffer[i])-StLow;
            R2Buffer[i]=PBuffer[cb]+(StHigh - StLow);
            R3Buffer[i]=(2*PBuffer[cb])+(StHigh-(2*StLow));
            S1Buffer[i]=(2*PBuffer[i])-StHigh;
            S2Buffer[i]=PBuffer[cb]-(StHigh - StLow);
            S3Buffer[i]=(2*PBuffer[cb])-((2* StHigh)-StLow);
         }
      }
   }
//-----------------
   return(0);
  }
//-----------------
datetime NormTimeBarBegin(datetime intime, int TF)
  {
   datetime outtime;
   if(TF!=10080)
   {
      outtime=MathFloor(intime/TF/60)*TF*60;
   }
   else
   {
      outtime=MathFloor((intime+345600)/TF/60)*TF*60-345600;
   }
   return(outtime);
  }
//-----------------
int n_iBarShift(datetime intime, int TF)
  {
   int bindex,b_count;
   datetime TArray[];
   b_count=ArrayCopySeries(TArray,MODE_TIME,Symbol(),TF);
   bindex=ArrayBsearch(TArray,NormTimeBarBegin(intime,TF),0,0,MODE_ASCEND) ;
   return(bindex);
  }
//-----------------  

Comments