_255ePivot_ResSup
Download scriptThis script is a specialized technical analysis tool designed for the MetaTrader platform. Its primary purpose is to automatically identify and project key price levels—specifically Pivot Points, Resistance, and Support—based on the price action of the previous trading day.
By utilizing these levels, the tool helps traders visualize important zones where price may face pressure, potentially reversing or consolidating. Here is a breakdown of how the logic operates:
Core Functionality
The script monitors daily price movements to calculate three critical benchmarks for the current trading session:
- Pivot Point: The central balance point of the previous day's price range.
- Resistance Level: A projected "ceiling" where buying pressure might weaken.
- Support Level: A projected "floor" where selling pressure might weaken.
How the Logic Works
- Daily Identification: The script constantly monitors the chart to detect when a new trading day begins.
- Historical Data Analysis: Once a new day starts, the script looks back at the previous completed day. It specifically identifies three key data points from that period: the highest price reached (High), the lowest price reached (Low), and the final closing price (Close).
- Dynamic Calculation: Depending on the settings chosen by the user, the script applies a mathematical formula to these three data points to determine the Pivot Point. It then uses the relationship between the High, Low, and Pivot to mathematically project the corresponding Support and Resistance levels.
- Continuous Projection: As time progresses throughout the current day, the script "carries forward" these calculated levels. This ensures that the support and resistance lines remain constant and visible on your chart until the next trading day provides a new set of data.
Key Features for the User
- Timeframe Sensitivity: The tool is optimized to work on lower timeframes (anything 4 hours or less), making it ideal for day traders who need to see intraday levels clearly.
- Automated Visualization: Instead of manually calculating complex formulas, the script draws these levels directly on the chart as visual markers.
- Consistency: Because the levels are derived from a standardized formula based on the previous day's actual range, it provides a consistent framework for identifying potential entry and exit zones.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| ^Pivot_ResSup.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 2
#property indicator_color1 Blue
#property indicator_color2 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[];
double ResBuffer[];
double SupBuffer[];
//+------------------------------------------------------------------+
//| Ïðîâåðêà íîâîãî äíÿ |
//+------------------------------------------------------------------+
bool isNewDay(int _shift)
{
//----
result=false;
if ( (TimeHour(Time[_shift])==0) && (TimeMinute(Time[_shift])==0) ) result=true;
//----
return(result);
}
//+------------------------------------------------------------------+
//| Ïîëó÷èòü óðîâíè FP,Res1 è Sup1 ïðîøåäøåãî äíÿ |
//+------------------------------------------------------------------+
void GetRS1ofDay(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);
ResBuffer[_shift]=NormalizeDouble(FP+(FP-FL),Digits);
SupBuffer[_shift]=NormalizeDouble(FP-(FH-FP),Digits);
//----
}
//+------------------------------------------------------------------+
//| Êîïèðîâàòü FP,Res1 è Sup1 ïðîøåäøåãî äíÿ |
//+------------------------------------------------------------------+
void CopyLevels1Day(int _shift)
{
ExtMapBuffer1[_shift]=ExtMapBuffer1[_shift];
ResBuffer[_shift]=ResBuffer[_shift+1];
SupBuffer[_shift]=SupBuffer[_shift+1];
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
if (Formula!=0)Formula=1;
string label1="Pivot_Res("+Formula+")";
string label2="Pivot_Sup("+Formula+")";
//---- indicators
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,160);
SetIndexBuffer(0,ResBuffer);
SetIndexEmptyValue(0,0.0);
SetIndexLabel(0,label2);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,160);
SetIndexBuffer(1,SupBuffer);
SetIndexEmptyValue(1,0.0);
SetIndexLabel(1,label2);
SetIndexBuffer(0,ExtMapBuffer1);
//----
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)) GetRS1ofDay(shift); else CopyLevels1Day(shift);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments