AFL for Pivot Point (static)

#1
I need some help in a new AFL creation (may be this already exists!!!)

Based on: Pivot Points

Formula: Classical Pivot Points

Pivot point (PP) : (High + Low + Close)/3
First support (S1) : (2 x PP) - High
Second Support (S2) : PP - (High - Low)
Third Support (S3) : Low - 2*(High - Pivot)
First Resistance (R1) : (2 x PP) - Low
Second Resistance (R2) : PP + (High - Low)
Third resistance (R3) : High + 2*(Pivot – Low)

Idea: Apart from using the pivot points for the previous day OHLC, I also want to use it for some important candles across different timeframes.

Requirement:
1. If I drag and drop the afl on the chart, for instance with timeframe 1hour, it should ask for the color parameters for pivot, support and resistance.

2. After selecting the colors, if I click on any candle, the pivot lines should be plotted and remain static i.e the pivot lines should not change if I move the mouse over other candles.

3. If the change the chart timeframe, for instance to 3 minute, still the pivot lines should remain intact.

4. If I drag and drop the same afl again, it should repeat step 1 to 3.

I'm not good in coding, but can pick up with some assistance. Please assist and the help would be much appreciated.

Thanks :thumb:
 

KelvinHand

Well-Known Member
#2
I need some help in a new AFL creation (may be this already exists!!!)

Based on: Pivot Points

Formula: Classical Pivot Points

Pivot point (PP) : (High + Low + Close)/3
First support (S1) : (2 x PP) - High
Second Support (S2) : PP - (High - Low)
Third Support (S3) : Low - 2*(High - Pivot)
First Resistance (R1) : (2 x PP) - Low
Second Resistance (R2) : PP + (High - Low)
Third resistance (R3) : High + 2*(Pivot – Low)

Idea: Apart from using the pivot points for the previous day OHLC, I also want to use it for some important candles across different timeframes.

Requirement:
1. If I drag and drop the afl on the chart, for instance with timeframe 1hour, it should ask for the color parameters for pivot, support and resistance.

2. After selecting the colors, if I click on any candle, the pivot lines should be plotted and remain static i.e the pivot lines should not change if I move the mouse over other candles.

3. If the change the chart timeframe, for instance to 3 minute, still the pivot lines should remain intact.

4. If I drag and drop the same afl again, it should repeat step 1 to 3.

I'm not good in coding, but can pick up with some assistance. Please assist and the help would be much appreciated.

Thanks :thumb:
This kind of common afl and you know it existing, please do a bit of re-search instead of spending time writing your requirement.
Google wisestock pivot point or search in TJ thread you will get it.
No need to reinvent the wheel.
 
#3
This kind of common afl and you know it existing, please do a bit of re-search instead of spending time writing your requirement.
Google wisestock pivot point or search in TJ thread you will get it.
No need to reinvent the wheel.
Thanks for your response. Actually, I did do research, but couldn't find what I expect, hence the post. Most of the AFL I tried are having pivot lines changing for different candles or static pivot lines based on previous day. I need an intraday pivot point calculator for one single candle that I select.
 

KelvinHand

Well-Known Member
#4
Thanks for your response. Actually, I did do research, but couldn't find what I expect, hence the post. Most of the AFL I tried are having pivot lines changing for different candles or static pivot lines based on previous day. I need an intraday pivot point calculator for one single candle that I select.
Then look at this pivot points that can customize for intraday
http://www.wisestocktrader.com/indicatorpasties/195-pivot-points.

try out the "Classical" 1~4 hour timeframe
 

KelvinHand

Well-Known Member
#5
Then look at this pivot points that can customize for intraday
http://www.wisestocktrader.com/indicatorpasties/195-pivot-points.

try out the "Classical" 1~4 hour timeframe
The StockManiacs' Pivot Point had some minor bugs.
I modified & created this classic pivot points for all time frames.

Here the features:
1. Select Hour, Min, Day Week, Month multiplier
2. Default setting is 1 [Hour/Min/Day/Week/Month]
3. Changeable colors for Pivot, Res., Sup. levels
4. Changeable Styles for Pivot, R1S1, R2S2, R3S3 levels

Example:

To configure 30Min Pivot levels
- Use 'Min' Multipiler
- Set 'Interval' to 30


PHP:
_SECTION_BEGIN ("Chart Setup");
SetChartBkColor(ParamColor("Outer panel",colorSkyblue));
SetChartBkGradientFill(
ParamColor("Upper Inner panel",colorLightBlue),
ParamColor("Lower Inner panel",colorLightYellow)); 

SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);

//basic price plotting
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END ();

_SECTION_BEGIN ("Pivot Levels");

//--- Created by : KelvinHand -------
T_F =ParamList("TF Multiplier","Hour|Min|Day|Week|Month");
iInterval = Param("Interval", 1, 1);

Note1=ParamStr("-- Colors --", "PP, S1..S3, R1..R3");
PP_Color=ParamColor("PP Color",colorViolet);
Rn_Color=ParamColor("Rn Color",colorDarkRed);
Sn_Color=ParamColor("Sn Color",colorDarkGreen);
 
Note1=ParamStr("-- Styles --", "PP, R1S1, R2S2, R3S3");
PP_Style=ParamStyle("PP", styleDots|styleThick, maskAll);
R1S1_Style=ParamStyle("R1S1 Style", styleThick, maskAll);
R2S2_Style=ParamStyle("R2S2 Style", styleLine,  maskAll);
R3S3_Style=ParamStyle("R3S3 Style", styleDashed,maskAll);



_SECTION_END ();


shift=-1;

switch (T_F)
{
	case "Day": 	iPeriod  = inDaily;		break;
	case "Hour":	iPeriod  = inHourly;	break;
	case "Min":		iPeriod  = in1Minute;	break;
}
     
  
     xTF = iInterval*iPeriod;
		H1 = TimeFrameGetPrice( "H", xTF, shift );
		L1 = TimeFrameGetPrice( "L", xTF, shift );
		C1 = TimeFrameGetPrice( "C", xTF, shift );

// To calculate the Pivot Levels 
  PP = (H1 + L1 + C1) / 3;
	R1 = (2 * PP) - L1 ;
	S1 = (2 * PP) - H1 ;
	R2 = PP - s1 + r1;
	S2 = PP - (r1 - s1) ;
	R3 = 2 * (PP - L1) + H1 ;
	S3 = L1 - (2 * (H1 - PP));


//	Plot Pivot Levels in the charts

Plot (PP,"",PP_Color,PP_Style);

Plot (R1,"",Rn_Color,R1S1_Style);
Plot (S1,"",Sn_Color,R1S1_Style);

Plot (R2,"",Rn_Color,R2S2_Style);
Plot (S2,"",Sn_Color,R2S2_Style);

Plot (R3,"",Rn_Color,R3S3_Style);
Plot (S3,"",Sn_Color,R3S3_Style);

//	Add Pivot levels on charts as text
Title = Title + EncodeColor(colorDarkTeal)+
"\nPivot T_F = "+NumToStr(iInterval,1.0)+" "+T_F + "\n" +
EncodeColor(Rn_Color)+"R3 = "+ r3 +"\n"+
EncodeColor(Rn_Color)+"R2 = "+ r2 + "\n"+
EncodeColor(Rn_Color)+"R1 = "+ r1 + "\n"+ "\n"+
EncodeColor(PP_Color)+"PP = "+ PP + "\n"+ "\n" +
EncodeColor(Sn_Color)+"S1 = "+ s1 + "\n"+
EncodeColor(Sn_Color)+"S2 = "+ s2 + "\n"+
EncodeColor(Sn_Color)+"S3 = "+ s3 + "\n";

_SECTION_END ();
 
Last edited:
#7
The StockManiacs' Pivot Point had some minor bugs.
I modified & created this classic pivot points for all time frames.

Here the features:
1. Select Hour, Min, Day Week, Month multiplier
2. Default setting is 1 [Hour/Min/Day/Week/Month]
3. Changeable colors for Pivot, Res., Sup. levels
4. Changeable Styles for Pivot, R1S1, R2S2, R3S3 levels

Example:

To configure 30Min Pivot levels
- Use 'Min' Multipiler
- Set 'Interval' to 30
Hello

Just a small addition to the above code based on a request from fellow trader. who wanted to use . . .

/*
BC = (High + Low)/2
TC = (Pivot - BC) + Pivot
*/


PHP:
_SECTION_BEGIN ("Chart Setup");
SetChartBkColor(ParamColor("Outer panel",colorSkyblue));
SetChartBkGradientFill(
ParamColor("Upper Inner panel",colorLightBlue),
ParamColor("Lower Inner panel",colorLightYellow)); 

SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);

//basic price plotting
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END ();

_SECTION_BEGIN ("Pivot Levels");

//--- Created by : KelvinHand -------
T_F =ParamList("TF Multiplier","Hour|Min|Day|Week|Month");
iInterval = Param("Interval", 1, 1);

Note1=ParamStr("-- Colors --", "PP, S1..S3, R1..R3");
PP_Color=ParamColor("PP Color",colorViolet);
Rn_Color=ParamColor("Rn Color",colorDarkRed);
Sn_Color=ParamColor("Sn Color",colorDarkGreen);
 
Note1=ParamStr("-- Styles --", "PP, R1S1, R2S2, R3S3");
PP_Style=ParamStyle("PP", styleDots|styleThick, maskAll);
R1S1_Style=ParamStyle("R1S1 Style", styleThick, maskAll);
R2S2_Style=ParamStyle("R2S2 Style", styleLine,  maskAll);
R3S3_Style=ParamStyle("R3S3 Style", styleDashed,maskAll);



_SECTION_END ();


shift=-1;

switch (T_F)
{
    case "Day":     iPeriod  = inDaily;        break;
    case "Hour":    iPeriod  = inHourly;    break;
    case "Min":        iPeriod  = in1Minute;    break;
}
     
  
     xTF = iInterval*iPeriod;
        H1 = TimeFrameGetPrice( "H", xTF, shift );
        L1 = TimeFrameGetPrice( "L", xTF, shift );
        C1 = TimeFrameGetPrice( "C", xTF, shift );

// To calculate the Pivot Levels 
  	PP = (H1 + L1 + C1) / 3;

    R1 = (2 * PP) - L1 ;
    S1 = (2 * PP) - H1 ;
    R2 = PP - s1 + r1;
    S2 = PP - (r1 - s1) ;
    R3 = 2 * (PP - L1) + H1 ;
    S3 = L1 - (2 * (H1 - PP));

//    Plot Pivot Levels in the charts

Plot (PP,"",PP_Color,PP_Style);

Plot (R1,"",Rn_Color,R1S1_Style);
Plot (S1,"",Sn_Color,R1S1_Style);

Plot (R2,"",Rn_Color,R2S2_Style);
Plot (S2,"",Sn_Color,R2S2_Style);

Plot (R3,"",Rn_Color,R3S3_Style);
Plot (S3,"",Sn_Color,R3S3_Style);

/*
BC = (High + Low)/2
TC = (Pivot - BC) + Pivot
*/

BC = (H1 + L1)/2;
TC = (PP - BC) + PP;
PlotOHLC(TC,BC,TC,BC,"",colorGrey50,styleNoLabel|styleCloud);


//    Add Pivot levels on charts as text
Title = Title + EncodeColor(colorDarkTeal)+
"\nPivot T_F = "+NumToStr(iInterval,1.0)+" "+T_F + "\n" +
EncodeColor(Rn_Color)+"R3 = "+ r3 +"\n"+
EncodeColor(Rn_Color)+"R2 = "+ r2 + "\n"+
EncodeColor(Rn_Color)+"R1 = "+ r1 + "\n"+ "\n"+
EncodeColor(PP_Color)+"PP = "+ PP + "\n"+ "\n" +
EncodeColor(Sn_Color)+"S1 = "+ s1 + "\n"+
EncodeColor(Sn_Color)+"S2 = "+ s2 + "\n"+
EncodeColor(Sn_Color)+"S3 = "+ s3 + "\n";

_SECTION_END ();
Cheers

:) Happy
 

KelvinHand

Well-Known Member
#8
Hello

Just a small addition to the above code based on a request from fellow trader. who wanted to use . . .

/*
BC = (High + Low)/2
TC = (Pivot - BC) + Pivot
*/


PHP:
_SECTION_BEGIN ("Chart Setup");
SetChartBkColor(ParamColor("Outer panel",colorSkyblue));
SetChartBkGradientFill(
ParamColor("Upper Inner panel",colorLightBlue),
ParamColor("Lower Inner panel",colorLightYellow)); 

SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);

//basic price plotting
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END ();

_SECTION_BEGIN ("Pivot Levels");

//--- Created by : KelvinHand -------
T_F =ParamList("TF Multiplier","Hour|Min|Day|Week|Month");
iInterval = Param("Interval", 1, 1);

Note1=ParamStr("-- Colors --", "PP, S1..S3, R1..R3");
PP_Color=ParamColor("PP Color",colorViolet);
Rn_Color=ParamColor("Rn Color",colorDarkRed);
Sn_Color=ParamColor("Sn Color",colorDarkGreen);
 
Note1=ParamStr("-- Styles --", "PP, R1S1, R2S2, R3S3");
PP_Style=ParamStyle("PP", styleDots|styleThick, maskAll);
R1S1_Style=ParamStyle("R1S1 Style", styleThick, maskAll);
R2S2_Style=ParamStyle("R2S2 Style", styleLine,  maskAll);
R3S3_Style=ParamStyle("R3S3 Style", styleDashed,maskAll);



_SECTION_END ();


shift=-1;

switch (T_F)
{
    case "Day":     iPeriod  = inDaily;        break;
    case "Hour":    iPeriod  = inHourly;    break;
    case "Min":        iPeriod  = in1Minute;    break;
}
     
  
     xTF = iInterval*iPeriod;
        H1 = TimeFrameGetPrice( "H", xTF, shift );
        L1 = TimeFrameGetPrice( "L", xTF, shift );
        C1 = TimeFrameGetPrice( "C", xTF, shift );

// To calculate the Pivot Levels 
  	PP = (H1 + L1 + C1) / 3;

    R1 = (2 * PP) - L1 ;
    S1 = (2 * PP) - H1 ;
    R2 = PP - s1 + r1;
    S2 = PP - (r1 - s1) ;
    R3 = 2 * (PP - L1) + H1 ;
    S3 = L1 - (2 * (H1 - PP));

//    Plot Pivot Levels in the charts

Plot (PP,"",PP_Color,PP_Style);

Plot (R1,"",Rn_Color,R1S1_Style);
Plot (S1,"",Sn_Color,R1S1_Style);

Plot (R2,"",Rn_Color,R2S2_Style);
Plot (S2,"",Sn_Color,R2S2_Style);

Plot (R3,"",Rn_Color,R3S3_Style);
Plot (S3,"",Sn_Color,R3S3_Style);

/*
BC = (High + Low)/2
TC = (Pivot - BC) + Pivot
*/

BC = (H1 + L1)/2;
TC = (PP - BC) + PP;
PlotOHLC(TC,BC,TC,BC,"",colorGrey50,styleNoLabel|styleCloud);


//    Add Pivot levels on charts as text
Title = Title + EncodeColor(colorDarkTeal)+
"\nPivot T_F = "+NumToStr(iInterval,1.0)+" "+T_F + "\n" +
EncodeColor(Rn_Color)+"R3 = "+ r3 +"\n"+
EncodeColor(Rn_Color)+"R2 = "+ r2 + "\n"+
EncodeColor(Rn_Color)+"R1 = "+ r1 + "\n"+ "\n"+
EncodeColor(PP_Color)+"PP = "+ PP + "\n"+ "\n" +
EncodeColor(Sn_Color)+"S1 = "+ s1 + "\n"+
EncodeColor(Sn_Color)+"S2 = "+ s2 + "\n"+
EncodeColor(Sn_Color)+"S3 = "+ s3 + "\n";

_SECTION_END ();
Cheers

:) Happy
No Problem.
But move the Cloud behind, it block the sunlight:D
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?