Floor_Pivots_Daily_Mid
Download scriptOverview of the Floor Pivots Daily Mid Script
This script is designed to provide traders with a visual roadmap of key price levels based on historical market activity. By identifying specific "Pivot Points," it helps traders understand where the price might experience significant shifts, support, or resistance during a trading day. Instead of just showing standard high and low points, this tool calculates intermediate zones (mid-points) between major levels to provide a more nuanced view of market structure.
How the Logic Works
1. Timeframe and Period Monitoring The script is specifically optimized for intraday trading. It requires the chart to be set to a timeframe of 4 hours or less. It continuously scans the historical data to identify specific time windows (defined by the user) to determine the range of the previous market session.
2. Identifying the Baseline Range To calculate the levels, the script first looks at a specific "Look-back" period. It identifies three core pieces of data from this period:
- The Highest price reached.
- The Lowest price reached.
- The Closing price of the session.
3. The Calculation Process Once those three values are identified, the script uses a mathematical formula to establish several levels:
- Pivot Point (PP): The central balance point of the previous range.
- Pivot Deviation: The distance between the midpoint of the range and the Pivot Point. This determines the "width" of the market's movement.
- Resistance & Support Levels: Based on these calculations, the script generates standard R1, R2, S1, and S2 levels (representing areas where price might struggle to move higher or lower).
4. Mid-Point Refinement (The "Mid" Logic) What makes this specific script unique is its focus on "Mid" levels. Rather than just marking the major boundaries, it calculates the exact center points between key milestones:
- R1–R2 Mid: The halfway point between the first and second resistance zones.
- PP–R1 Mid: The halfway point between the central Pivot Point and the first resistance.
- PP–S1 Mid: The halfway point between the central Pivot Point and the first support.
- S1–S2 Mid: The halfway point between the first and second support zones.
Visual Representation on the Chart
The script translates these complex calculations into visual markers on your trading screen. It places specific symbols (arrows) at these calculated price points. This allows you to see at a glance:
- Where the "fair value" of the market sits today.
- Exactly where the halfway marks between major supply and demand zones are located.
By focusing on these intermediate mid-points, the tool helps traders identify potential "rebound" zones or "breakout" points more precisely than standard pivot indicators alone.
//+------------------------------------------------------------------+
//| Floor_Pivots_Daily_Mid.mq4 |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 C'200,200,200'
#property indicator_color2 C'100,100,100'
#property indicator_color3 C'100,100,100'
#property indicator_color4 C'000,100,000'
#property indicator_color5 C'000,100,000'
#property indicator_color6 C'100,000,000'
#property indicator_color7 C'100,000,000'
//Input Params
extern string PivotStart = "22:00";
extern string PivotEnd = "22:00";
double Buffer1[]; // Pivot Point
double Buffer2[]; // PivotRangeHigh
double Buffer3[]; // PivotRangeLow
double Buffer4[]; // Mid R1-R2
double Buffer5[]; // Mid PP-R1
double Buffer6[]; // Mid PP-S1
double Buffer7[]; // Mid S1-S2
double LastHigh,LastLow,LastClose;
double PivP, PivD, PivH, PivL;
double PivotRangeHigh, PivotRangeLow;
double PivR1, PivR2, PivR3;
double PivS1, PivS2, PivS3;
double PPR1, R1R2, PPS1, S1S2;
int OpenBar;
int init()
{ SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,167);
SetIndexBuffer(0,Buffer1);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,160);
SetIndexBuffer(1,Buffer2);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,160);
SetIndexBuffer(2,Buffer3);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,160);
SetIndexBuffer(3,Buffer4);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,160);
SetIndexBuffer(4,Buffer5);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,160);
SetIndexBuffer(5,Buffer6);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,160);
SetIndexBuffer(6,Buffer7);
return(0); }
int deinit()
{
ObjectDelete("PRP");
ObjectDelete("PRH");
ObjectDelete("PRL");
ObjectDelete("R2R1");
ObjectDelete("R1PP");
ObjectDelete("S1PP");
ObjectDelete("S2S1");
Comment("");
return(0);
}
int start()
{ if (Period() > 240) return(0); //Chart cannot be higher than H4
string BarTime="", LastBarTime="";
string BarDay="", LastBarDay="";
int 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);
//need to handle if pivotrangestart/end is 00:00
if ((PivotEnd == "00:00" && BarTime>=PivotEnd && BarDay>LastBarDay) || (BarTime>=PivotEnd && LastBarTime<PivotEnd))
{ CloseBar = i + 1;
if (OpenBar>0)
{ calculatePivotRangeValues(OpenBar, CloseBar); } }
if ((PivotStart == "00:00" && BarTime>=PivotStart && BarDay>LastBarDay) || (BarTime>=PivotStart && LastBarTime<PivotStart))
{ OpenBar = i; }
if (OpenBar>0)
{ drawIndicators(i); } }
return(0);}
void calculatePivotRangeValues(int openBar, int closeBar)
{
LastHigh = High[Highest(NULL, 0, MODE_HIGH, (openBar - closeBar + 1), closeBar)];
LastLow = Low[Lowest(NULL, 0, MODE_LOW, (openBar - closeBar + 1), closeBar)];
LastClose = Close[closeBar];
PivP = (LastHigh + LastLow + LastClose) / 3;
PivD = MathAbs(((LastHigh + LastLow)/2) - PivP);
PivotRangeHigh = PivP + PivD;
PivotRangeLow = PivP - PivD;
PivR3 = (2*PivP)+(LastHigh-(2*LastLow));
PivR2 = PivP+(LastHigh - LastLow);
PivR1 = (2*PivP)-LastLow;
PivS1 = (2*PivP)-LastHigh;
PivS2 = PivP-(LastHigh - LastLow);
PivS3 = (2*PivP)-((2* LastHigh)-LastLow);
R1R2 = (PivR1 + PivR2) / 2;
PPR1 = (PivP + PivR1) / 2;
PPS1 = (PivP + PivS1) / 2;
S1S2 = (PivS1 + PivS2) / 2;
}
void drawIndicators(int curBar)
{
// Buffer1[curBar] = PivP;
Buffer2[curBar] = PivotRangeHigh;
Buffer3[curBar] = PivotRangeLow;
Buffer4[curBar] = R1R2;
Buffer5[curBar] = PPR1;
Buffer6[curBar] = PPS1;
Buffer7[curBar] = S1S2;
DoLabel("PRP", Buffer1[0], indicator_color1);
//DoLabel("PRH", Buffer2[0], indicator_color2);
//DoLabel("PRL", Buffer3[0], indicator_color3);
DoLabel("R2R1", Buffer4[0], indicator_color4);
DoLabel("R1PP", Buffer5[0], indicator_color5);
DoLabel("S1PP", Buffer6[0], indicator_color6);
DoLabel("S2S1", Buffer7[0], indicator_color7);
return(0); }
void DoLabel( string dName, double dValue, color dColor )
{
if (ObjectFind(dName) != 0)
{
ObjectCreate(dName,OBJ_ARROW,0,Time[0],dValue);
ObjectSet(dName,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(dName,OBJPROP_COLOR,dColor);
}
else
{
ObjectMove(dName,0,Time[0],dValue);
}
}
//+-----------------------------------------------------------------------------------------+
//| THE END |
//+-----------------------------------------------------------------------------------------+
Comments