JPivot Points
Download scriptThis indicator is designed to provide traders with a comprehensive visual map of potential support and resistance levels on a trading chart. It utilizes a classic financial calculation known as "Pivot Points" to help identify key price zones where the market might encounter difficulty moving higher or lower.
How the Logic Works
The script operates by analyzing specific historical price data—specifically the High, Low, and Close prices—from a timeframe of your choosing (ranging from 1-minute intervals up to monthly charts). By processing these three core values, the tool automatically calculates several distinct price levels:
- The Pivot Point: This serves as the primary anchor or "equilibrium" level for the current period. It represents the central balance point between the highs and lows of the previous session.
- Resistance Levels (R1, R2): These lines identify ceilings where the price may face selling pressure. They represent potential targets for a downward reversal or areas where the upward momentum might exhaust.
- Support Levels (S1, S2): These lines identify floors where the price may find buying interest. They indicate zones where the downward trend might pause or bounce back upward.
Advanced Mid-Point Calculations
Beyond the standard levels, the script adds a layer of precision by calculating "Mid-Points." These are secondary markers that sit between the primary Pivot, Resistance, and Support lines:
- Resistance/Pivot Midpoints: These help identify "halfway" zones between the main pivot and its upper resistance targets.
- Support/Pivot Midpoints: These identify "halfway" zones between the main pivot and its lower support targets.
Key Features for the User
- Customizable Timeframes: You can toggle the logic to look at different time scales (e.g., Daily, Weekly, or Hourly) to match your specific trading style.
- Visual Organization: The script uses a color-coded system to differentiate between these various levels, allowing you to see clearly where the "danger zones" and "opportunity zones" are located on your screen at a glance.
- Automated Updates: The logic automatically cycles through historical data to ensure that as new candles form, the pivot levels adjust to reflect the most recent market behavior.
In summary, this tool transforms raw historical price data into a structured grid of price levels, allowing you to see potential "turning points" in the market more clearly than by looking at price action alone.
//+------------------------------------------------------------------+
//| JPivot Points.mq4 |
//| Copyright © 2006, juanchoc. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, juanchoc."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 9
#property indicator_color1 White
#property indicator_color2 Lime
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Blue
#property indicator_color7 Blue
#property indicator_color8 Blue
#property indicator_color9 Blue
//---- buffers
double P[];
double R1[];
double R2[];
double S1[];
double S2[];
double MR1R2[];
double MR1P[];
double MPS1[];
double MS1S2[];
extern int Loopback = 1;
extern int Timeframe = 7; // 1= 1m, 2= 5m, 3= 15m, 4= 30m, 5= 1h, 6= 4h, 7= 1d, 8= 1w, 9= 1mn, 10= current
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,P);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,R1);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,R2);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,S1);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,S2);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,MR1R2);
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(6,MR1P);
SetIndexStyle(7,DRAW_LINE);
SetIndexBuffer(7,MPS1);
SetIndexStyle(8,DRAW_LINE);
SetIndexBuffer(8,MS1S2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//---- check for possible errors
if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
if (counted_bars>0) counted_bars--;
int pos=Bars-counted_bars;
//----
double C;
double H;
double L;
int tf;
switch(Timeframe){
case 1:
tf = PERIOD_M1;
break;
case 2:
tf = PERIOD_M5;
break;
case 3:
tf = PERIOD_M15;
break;
case 4:
tf = PERIOD_M30;
break;
case 5:
tf = PERIOD_H1;
break;
case 6:
tf = PERIOD_H4;
break;
case 7:
tf = PERIOD_D1;
break;
case 8:
tf = PERIOD_W1;
break;
case 9:
tf = PERIOD_MN1;
break;
case 10:
tf = 0;
break;
}
while(pos>=0)
{
C = iClose(NULL, tf, Loopback);
H = iHigh(NULL, tf, Loopback);
L = iLow(NULL, tf, Loopback);
P[pos] = (H + L + C) / 3;
R1[pos] = (P[pos] * 2) - L;
R2[pos] = P[pos] + (H - L);
S1[pos] = (P[pos] * 2) - H;
S2[pos] = P[pos] - (H - L);
MR1R2[pos] = (R2[pos] + R1[pos]) / 2;
MR1P[pos] = (R1[pos] + P[pos]) / 2;
MPS1[pos] = (P[pos] + S1[pos]) / 2;
MS1S2[pos] = (S1[pos] + S2[pos]) / 2;
pos--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments