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 [4513] Corrected for Amibroker (AFL)

Copy & Paste Friendly
// Swing Trading ST [4513] by Edward Pottasch 24dec2014
// Editor's random spaces removed

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;

//============================================
Back