Skip to main content

Pivot Breakout System for Amibroker (AFL)

iris1in almost 13 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 8)
  • Tags:
    amibroker, pivot

This system is useful in Intraday TimeFrame to find the Pivot High/Low.

Base Time frame is 15min. circle(Pivots) above high or below low to show pivots are in real time. No text will be written above (PH) or below(PL) the candle as (text writing reduces afl execution speed a lot and also its position and size varies in AmiBroker). Circles appear immediately after the candle formation (in real time); however if the new pivot is formed within the lookback period in next candles, the circles would shift their position to the new pivot.

NOTE: Per your requirements, You will need to define “lookback period” to control the sensitivity of the pivots under Parameters.

Example : Default “Lookback period” is defined as 5. If a new higher pivot is formed on the last candle, circle will appear on that candle immediately. However if a new higher pivot is formed within next 5 candles, the previous circle will shift to the new higher pivot.

System can also trigger alert in the exploration when price closes below/above previous pivot. Irrespective of whichever timeframe your chart is, exploration will show result in all 5 timeframes (Base Time Frame,15M,30M,60M & Daily). During exploration, you will need to select the base timeframe under Automatic Analysis>>Setting>>Periodicity. Whenever there is a Pivot Breakout on the base timeframe, it will show result in the exploration with the status in base as well as the other 4 timeframes.

Parameters window would also give user an Option to Suppress the Successive Same Pivots. Alternate same pivots will be suppressed i.e. after a High pivot, all successive High pivots will be suppressed till you get a Low pivot (and vice versa).

Here is a screenshot of how the indicator & the Exploration looks:

Screenshots

Indicator / Formula

Copy & Paste Friendly
/**********************************************************************************
**************************Start of Pivot Breakout System***************************
                                   First Version.
**********************************************************************************/

_SECTION_BEGIN("Trading System - Parameters");
XGS=Param("Chart Height % ?",90,1,100);GraphXSpace=100-XGS;SetChartOptions(0,chartShowArrows|chartShowDates);SetBarsRequired(-2,-2);_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", colorBlack, styleNoTitle | styleCandle); 
SV_LP=Param("Lookback Period for pivot?",5,2,50,1); TimeFrameSet(in15Minute);PH = H > Ref(HHV(H,SV_LP),-1) AND Ref(HHV(H,SV_LP),SV_LP)<=H;PHP = ValueWhen(PH,H);PHPP = ValueWhen(PH,H,2);HHP = PHP>PHPP;LHP = PHP<PHPP;PL = L < Ref(LLV(L,SV_LP),-1) AND Ref(LLV(L,SV_LP),SV_LP)>=L;PLP = ValueWhen(PL,L);PLPP = ValueWhen(PL,L,2);LLP = PLP<PLPP;HLP = PLP>PLPP;
SV_SC15M = C<PLP AND HHP AND HLP;SV_BC15M = C>PHP AND LLP AND LHP;TimeFrameRestore();TimeFrameSet(30*in1Minute);	PH = H > Ref(HHV(H,SV_LP),-1) AND Ref(HHV(H,SV_LP),SV_LP)<=H;PHP = ValueWhen(PH,H);PHPP = ValueWhen(PH,H,2);HHP = PHP>PHPP;LHP = PHP<PHPP;PL = L < Ref(LLV(L,SV_LP),-1) AND Ref(LLV(L,SV_LP),SV_LP)>=L;PLP = ValueWhen(PL,L);	PLPP = ValueWhen(PL,L,2);	LLP = PLP<PLPP;	HLP = PLP>PLPP;	SV_SC30M = C<PLP AND HHP AND HLP;	SV_BC30M = C>PHP AND LLP AND LHP; TimeFrameRestore();
TimeFrameSet(60*in1Minute);	PH = H > Ref(HHV(H,SV_LP),-1) AND Ref(HHV(H,SV_LP),SV_LP)<=H;	PHP = ValueWhen(PH,H);	PHPP = ValueWhen(PH,H,2);	HHP = PHP>PHPP;	LHP = PHP<PHPP;PL = L < Ref(LLV(L,SV_LP),-1) AND Ref(LLV(L,SV_LP),SV_LP)>=L;	PLP = ValueWhen(PL,L);	PLPP = ValueWhen(PL,L,2);	LLP = PLP<PLPP;	HLP = PLP>PLPP;	SV_SC60M = C<PLP AND HHP AND HLP;	SV_BC60M = C>PHP AND LLP AND LHP; TimeFrameRestore();
TimeFrameSet(inDaily);PH = H > Ref(HHV(H,SV_LP),-1) AND Ref(HHV(H,SV_LP),SV_LP)<=H;PHP = ValueWhen(PH,H);PHPP = ValueWhen(PH,H,2);	HHP = PHP>PHPP;LHP = PHP<PHPP;	PL = L < Ref(LLV(L,SV_LP),-1) AND Ref(LLV(L,SV_LP),SV_LP)>=L;	PLP = ValueWhen(PL,L);PLPP = ValueWhen(PL,L,2);LLP = PLP<PLPP;HLP = PLP>PLPP;SV_SCDaily = C<PLP AND HHP AND HLP;SV_BCDaily = C>PHP AND LLP AND LHP;TimeFrameRestore();
PH = H > Ref(HHV(H,SV_LP),-1) AND Ref(HHV(H,SV_LP),SV_LP)<=H;PHP = ValueWhen(PH,H);PHPP = ValueWhen(PH,H,2);HHP = PHP>PHPP;LHP = PHP<PHPP;PL = L < Ref(LLV(L,SV_LP),-1) AND Ref(LLV(L,SV_LP),SV_LP)>=L;PLP = ValueWhen(PL,L);PLPP = ValueWhen(PL,L,2);LLP = PLP<PLPP;	HLP = PLP>PLPP;
SV_SC = C<PLP AND HHP AND HLP;	SV_BC = C>PHP AND LLP AND LHP; if(ParamToggle("Suppress Successive Same Pivots?","No,Yes")){	PH = ExRem(PH,PL);PL = ExRem(PL,PH);}if(Interval()<inDaily){SV_SC = ExRem(SV_SC,PH);SV_BC = ExRem(SV_BC,PL);}
PlotShapes(IIf(SV_SC,shapeDownTriangle,shapeNone),colorRed,0,H,-25);	PlotShapes(IIf(SV_BC,shapeUpTriangle,shapeNone),colorGreen,0,L,-25);AlertIf(SV_BC,"SOUND C:\\Windows\\Media\\tada.wav","Upward Breakout at :"+C,1);AlertIf(SV_SC,"SOUND C:\\Windows\\Media\\notify.wav","Downward Breakout at :"+C,2);if(ParamToggle("Plot Pivots?","No,Yes",1)){PlotShapes(IIf(PH,shapeSmallCircle,shapeNone),colorGreen,0,H,12);PlotShapes(IIf(PL,shapeSmallCircle,shapeNone),colorRed,0,L,-12);}Filter = SV_BC OR SV_SC OR
TimeFrameExpand(SV_BC15M,in15Minute) OR TimeFrameExpand(SV_BC30M,30*in1Minute) OR TimeFrameExpand(SV_BC60M,60*in1Minute) OR TimeFrameExpand(SV_BCDaily,inDaily) OR TimeFrameExpand(SV_SC15M,in15Minute) OR TimeFrameExpand(SV_SC30M,30*in1Minute) OR TimeFrameExpand(SV_SC60M,60*in1Minute) OR TimeFrameExpand(SV_SCDaily,inDaily);
AddColumn(IIf(SV_BC,89,78),"+ve in Base TF",formatChar,colorWhite,colorGreen);AddColumn(IIf(TimeFrameExpand(SV_BC15M,in15Minute),89,78),"+ve in 15m",formatChar,colorWhite,colorGreen);AddColumn(IIf(TimeFrameExpand(SV_BC30M,30*in1Minute),89,78),"+ve in 30m",formatChar,colorWhite,colorGreen);AddColumn(IIf(TimeFrameExpand(SV_BC60M,60*in1Minute),89,78),"+ve in 60m",formatChar,colorWhite,colorGreen);AddColumn(IIf(TimeFrameExpand(SV_BCDaily,inDaily),89,78),"+ve in Daily",formatChar,colorWhite,colorGreen);
AddColumn(IIf(SV_SC,89,78),"-ve in Base TF",formatChar,colorWhite,colorRed);AddColumn(IIf(TimeFrameExpand(SV_SC15M,in15Minute),89,78),"-ve in 15m",formatChar,colorWhite,colorRed);AddColumn(IIf(TimeFrameExpand(SV_SC30M,30*in1Minute),89,78),"-ve in 30m",formatChar,colorWhite,colorRed);AddColumn(IIf(TimeFrameExpand(SV_SC60M,60*in1Minute),89,78),"-ve in 60m",formatChar,colorWhite,colorRed);AddColumn(IIf(TimeFrameExpand(SV_SCDaily,inDaily),89,78),"-ve in Daily",formatChar,colorWhite,colorRed);
_SECTION_END();

/*************************End of Pivot Breakout System***************************/

12 comments

2. hmsanil
almost 13 years ago

Hi,

Its good.

Can u add the code for 5 minutes as well, as u have set the code starting from 15 minutes only.

Eagerly waiting

Thank you

3. iris1in
almost 13 years ago

hmsanil,

Second Line in the code: TimeFrameSet(in15Minute);

Change it to your requirements.

Regards,
iris

4. hmsanil
almost 13 years ago

Hi iris,

Thank you

Is this correct

TimeFrameSet(in5Minute);

PH = H > Ref(HHV(H,SV_LP),-1) AND Ref(HHV(H,SV_LP),SV_LP)<=H;

PHP = ValueWhen(PH,H);

PHPP = ValueWhen(PH,H,2);

HHP = PHP>PHPP;

LHP = PHP<PHPP;

PL = L < Ref(LLV(L,SV_LP),-1) AND Ref(LLV(L,SV_LP),SV_LP)>=L;

PLP = ValueWhen(PL,L);

PLPP = ValueWhen(PL,L,2);

LLP = PLP<PLPP;HLP = PLP>PLPP;

SV_SC5M = C<PLP AND HHP AND HLP;

SV_BC5M = C>PHP AND LLP AND LHP;

TimeFrameRestore();

Waiting for your response

Thank You

almost 13 years ago

iris1in,

Hello, excuse my English. I liked your other afl, wanted to use it to route orders in an automated fashion. I do not know programming. Could help me.
thiago.trades @ gmail.com.
Congratulations once again and thank you for your attention.

7. Nadjib
almost 13 years ago

First I would like to thank wiestocktrader.com
I asked for an email address who make this AFL "Pivot Breakout System for Amibroker Thank for your help to get email .
nadjibkaliyoso@yahoo.co.id

almost 13 years ago

Nadjib, I haven’t given you anyone’s email. That is against the privacy policy of this site.

11. acedubai
about 8 years ago

Hello Iris
Thanks for this wonderful indicator. Please, need some clarity on the arrows formed in exploration. When the Pivots are broken the arrows are formed. Subsequently also, the pivots are broken, but the arrows don’t form. How?

Leave Comment

Please login here to leave a comment.