Please help- AFL for swing points

#1
Hi,

Request AFL experts to help code the afl for swing points.

1) SPH- today is the HH as compare to next 5 bars.
2) SPL- today is the LL as compare to next 5 bars.

bar fulfilling condition 1 should have dot/circle above it high and bar fufilling condition 2 should have dot/circle below its low.

Once the count has started for any bar in between bars should not be considered for same swing point. I am attaching a chart where I have done it manually.

Bar A - its a SPL as next 5 bars has higher low than bar A low. Now count starts for SPL by comaparing next 5 bars so till this count is over new count must not started for SPL. Like bar 1 after bar A also has low lower than next 5 bars but since count is already going on from bar A ,bar 1 count must not be started. SPH count can be started as it opposite.

same way Bar B is SPH. as it high is higher than next 5 bars. Bar 1 after Bar B also fulfills the condition but it should not be consider to start a new count as count is already on from bar B. SPL count can be started as it is opposite swing point.

Same way I have marked rest of the SPH/SPL in alphabets

Please help,
S
 

casoni

Well-Known Member
#2
Hello
Here's the basic code
x = Cum(1);
ReX = LastValue(x)-x;
SPH =H > Ref(H,5) & H > Ref(H,4) & H > Ref(H,3) & H > Ref(H,2) & H > Ref(H,1)
& H > Ref(H,-1) & H > Ref(H,-2) & ReX >2;
PlotShapes(IIf(SPH,shapeSmallCircle, Null),colorRed,0,H,13);

SPL =L < Ref(L,5) & L < Ref(L,5) & L < Ref(L,3) & L < Ref(L,2) & L < Ref(L,1)
& L < Ref(L,-1) & L < Ref(L,-2) & ReX >2;
PlotShapes(IIf(SPL,shapeSmallCircle,Null),colorLime,0,L,-13);

Plot(C,"",2,128);

Now lets wait for senior / expert member to throw some more light on this concept
Thank you
 
Last edited:
#5
Hello
Here's the basic code
x = Cum(1);
ReX = LastValue(x)-x;
SPH =H > Ref(H,5) & H > Ref(H,4) & H > Ref(H,3) & H > Ref(H,2) & H > Ref(H,1)
& H > Ref(H,-1) & H > Ref(H,-2) & ReX >2;
PlotShapes(IIf(SPH,shapeSmallCircle, Null),colorRed,0,H,13);

SPL =L < Ref(L,5) & L < Ref(L,5) & L < Ref(L,3) & L < Ref(L,2) & L < Ref(L,1)
& L < Ref(L,-1) & L < Ref(L,-2) & ReX >2;
PlotShapes(IIf(SPL,shapeSmallCircle,Null),colorLime,0,L,-13);

Plot(C,"",2,128);

Now lets wait for senior / expert member to throw some more light on this concept
Thank you


sirji please add quote price also beside swing hi and low. Please add it for quick information on price movement.

thanks
 

bunti_k23

Well-Known Member
#6
Isnt it looking into the future bars .5,4,3,2,1.:confused: