Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Swing Trading ST for Amibroker (AFL)

Rating:
3 / 5 (Votes 7)
Tags:
swing, Gap, amibroker

Hello Everone,

This concept was discussed on Traderji by Smart_Trader

and this concept is coded By Edward Pottasch

Many Many Thanks to Edward Pottasch , for taking out his precious time and coded this concept

for Details about this concept check this
http://www.traderji.com/day-trading/49521-thoughts-day-swing-trading.html

Indicator / Formula

Copy & Paste Friendly
// Edward Pottasch 24dec2014
SetBarsRequired(sbrAll,sbrAll); 
xx=BarIndex();x=xx;Lx=LastValue(x); 
rightStrength=Optimize("R_S",Param("R_S",3,1,50,1) ,1,50,1); 
leftStrength=Optimize("L_S",Param("L_S",3,1,50,1), 1,50,1); 

function pkID(rightStrength,leftStrength) 
{ 
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength); 
return pk; 
} 
function trID(rightStrength,leftStrength) 
{ 
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength); 
return tr; 
} 

pk=pkID(rightStrength,leftStrength); 
tr=trID(rightStrength,leftStrength); 


SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0 ,chartShowDates); 
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorR ed,colorLightGrey))); 
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,col orDarkRed,colorLightGrey)),64,null,null,0,0,1); 
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>rightStrength,ColorRGB(0,100,0),co lorWhite),0,L,-10); 
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>rightStrength,ColorRGB(255,0,0),co lorWhite),0,H,10); 

pkHigh1=Ref(ValueWhen(pk,H,1),-(rightStrength+1)); 
trLow1=Ref(ValueWhen(Tr,L,1),-(rightStrength+1)); 
pkHigh0=ValueWhen(pk,H,0); 
trLow0=ValueWhen(Tr,L,0); 

upGap=Cross(C,pkHigh1) AND pkHigh1<trLow0; 
dnGap=Cross(trLow1,C) AND trLow1>pkHigh0; 

gapBaseUp=ValueWhen(upGap,pkHigh1); 
gapBaseDn=ValueWhen(dnGap,trLow1); 
gapExtrUp=ValueWhen(upGap,trLow0); 
gapExtrDn=ValueWhen(dnGap,pkHigh0); 

upGapArea=Flip(upGap,dnGap); 
dnGapArea=Flip(dnGap,upGap); 

gapBase=IIf(upGapArea,gapBaseUp,gapBaseDn); 
gapExtr=IIf(upGapArea,gapExtrUp,gapExtrDn); 

Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1); 
Plot(trLow1,"",colorRed,24,Null,Null,0,2,1); 
Plot(gapBase,"",colorlightgrey,styledashed,Null,Nu ll,0,2,1); 
Plot(gapExtr,"",colorlightgrey,styledashed,Null,Nu ll,0,2,1); 
PlotOHLC(gapBase,gapBase,gapExtr,gapExtr,"",IIf(ga pExtr>gapBase,colorseaGreen,colorOrange),styleClou d|styleNoRescale,Null,Null,0,-1,1);


strWeekday = StrMid("SunMonTueWedThuFriSat", SelectedValue(DayOfWeek())*3,3);
Title = EncodeColor(colorWhite)+ "Gap _ST style by Edward.P" + " - " + Name() + " - "+ "" + fullName() + " " +
EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +" - " + Date() + " # "+strWeekday + 
StrFormat("\nOp %g, Hi %g, Lo %g, Cl %g, Vol %g", O, H, L, C, V)+
"\nRight Bars: " + rightStrength + 
"\nLeft Bars : " + leftStrength;

//============================================

13 comments

1. pras

please give the link again because above link broken

2. davidalan

7 syntax error ab 5.91 lines 22-27

3. casoni

error due to older version of Amibroker
Try this

Plot(pkHigh1,"",colorBlue,24); 
Plot(trLow1,"",colorRed,24); 
Plot(gapBase,"",colorlightgrey,styledashed); 
Plot(gapExtr,"",colorlightgrey,styledashed); 
PlotOHLC(gapBase,gapBase,gapExtr,gapExtr,"",IIf(gapExtr>gapBase,
colorseaGreen,colorOrange),styleCloud|styleNoRescale);
 
4. davidalan

23 remove space red
24 remove space color
thank you working fine

5. parfumeur

Extra spaces, corrected version placed in [Pastie] section.

6. casoni

No need to use Above formula ,
As updated version of this concept is posted

Here…

7. bsedoha

Please provide the correct Trader ji link.

Thanks in advance

8. bsedoha

@ Casoni,

Is there is anyway by which we can add the buy and sell signal in it ??

Thanks in advance

9. astrosystems

this formula look into the future.

before:

before

after:

after

11. davidalan
Buy = upGap; Sell = dnGap; Buy = ExRem( Buy, Sell ); Sell = ExRem( Sell, Buy ); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,Low,-25); PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWHITE, 0,High,-25)
12. empottasch

you can’t always immediately say that a code looks into the future without understanding the code. Fractal type pivots always look into the future. That is why you need to wait until a pivot is completed before you can use it. Fractal type pivots are used to bring some structure in the price movement but you can’t buy/short at a fractal low or high as shown in the chart (unless you get lucky). Before a pivot is confirmed you always have to wait rightstrength + 1 bars.

here some code that adds signals (you can also toggle to system type signals):

http://wisestocktrader.com/indicatorpasties/1434-gapfill3b

13. davidalan

Mr Pottasch very solid idea, best programmer,i am a big fan, keep up your get work thanks, wishing you and yours a happy and healthy New Years

14. standris

try this:

// Edward Pottasch 24dec2014
SetBarsRequired(sbrAll,sbrAll); 
xx=BarIndex();x=xx;Lx=LastValue(x); 
rightStrength=Optimize("R_S",Param("R_S",3,1,50,1) ,1,50,1); 
leftStrength=Optimize("L_S",Param("L_S",3,1,50,1), 1,50,1); 

function pkID(rightStrength,leftStrength) 
{ 
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength); 
return pk; 
} 
function trID(rightStrength,leftStrength) 
{ 
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength); 
return tr; 
} 

pk=pkID(rightStrength,leftStrength); 
tr=trID(rightStrength,leftStrength); 


SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0 ,chartShowDates); 
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey))); 
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,null,null,0,0,1); 
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>rightStrength,ColorRGB(0,100,0),colorWhite),0,L,-10); 
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>rightStrength,ColorRGB(255,0,0),colorWhite),0,H,10); 

pkHigh1=Ref(ValueWhen(pk,H,1),-(rightStrength+1)); 
trLow1=Ref(ValueWhen(Tr,L,1),-(rightStrength+1)); 
pkHigh0=ValueWhen(pk,H,0); 
trLow0=ValueWhen(Tr,L,0); 

upGap=Cross(C,pkHigh1) AND pkHigh1<trLow0; 
dnGap=Cross(trLow1,C) AND trLow1>pkHigh0; 

gapBaseUp=ValueWhen(upGap,pkHigh1); 
gapBaseDn=ValueWhen(dnGap,trLow1); 
gapExtrUp=ValueWhen(upGap,trLow0); 
gapExtrDn=ValueWhen(dnGap,pkHigh0); 

upGapArea=Flip(upGap,dnGap); 
dnGapArea=Flip(dnGap,upGap); 

gapBase=IIf(upGapArea,gapBaseUp,gapBaseDn); 
gapExtr=IIf(upGapArea,gapExtrUp,gapExtrDn); 

Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1); 
Plot(trLow1,"",colorRed,24,Null,Null,0,2,1); 
Plot(gapBase,"",colorlightgrey,styledashed,Null,Null,0,2,1); 
Plot(gapExtr,"",colorlightgrey,styledashed,Null,Null,0,2,1); 
PlotOHLC(gapBase,gapBase,gapExtr,gapExtr,"",IIf(gapExtr>gapBase,colorseaGreen,colorOrange),styleCloud|styleNoRescale,Null,Null,0,-1,1);


strWeekday = StrMid("SunMonTueWedThuFriSat", SelectedValue(DayOfWeek())*3,3);
Title = EncodeColor(colorWhite)+ "Gap _ST style by Edward.P" + " - " + Name() + " - "+ "" + fullName() + " " +
EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +" - " + Date() + " # "+strWeekday + 
StrFormat("\nOp %g, Hi %g, Lo %g, Cl %g, Vol %g", O, H, L, C, V)+
"\nRight Bars: " + rightStrength + 
"\nLeft Bars : " + leftStrength;

//============================================

Leave Comment

Please login here to leave a comment.

Back