can any one add backtest and exploration in below afl
_section_begin("ha");
a=20;
graphxspace=5;
p=30;
p = param("p",30,2,100,1);
om=dema(o,p);
hm=dema(h,p);
lm=dema(l,p);
cm=dema(c,p);
haclose=(om+hm+lm+cm)/4;
haopen = ama( ref( haclose, -1), 1);
hahigh = max( hm, max( haclose, haopen ) );
halow = min( lm, min( haclose, haopen ) );
slope = param("slope",2,2,100,1);
color20= iif(linregslope(ma(haclose,a),slope)<0,colorred,colorblue);
color=iif(haclose>ma(haclose,a),colorblue, colorred);
plotohlc( haopen, haopen, haclose, haclose, "" + name(), color, stylecandle);
buy=cover= cross(haclose,ma(haclose,a));
sell=short= cross(ma(haclose,a),haclose);
plotshapes(iif(buy, shapesquare, shapenone),colorgreen, 0, l, offset=-40);
plotshapes(iif(buy, shapesquare, shapenone),colorlime, 0,l, offset=-50);
plotshapes(iif(buy, shapeuparrow, shapenone),colorwhite, 0,l, offset=-45);
plotshapes(iif(sell, shapesquare, shapenone),colorred, 0, h, offset=40);
plotshapes(iif(sell, shapesquare, shapenone),colororange, 0,h, offset=50);
plotshapes(iif(sell, shapedownarrow, shapenone),colorwhite, 0,h, offset=-45);
_section_end();
_section_begin("kpl swing with n&m swing");
setbarsrequired(200,0);
graphxspace = 5;
setchartoptions(0,chartshowarrows|chartshowdates);
k = optimize("k",param("k",3,0.25,5,0.25),0.25,5,0.25);
per= optimize("atr",param("atr",10,3,20,1),3,20,1);
haclose=(o+h+l+c)/4;
haopen = ama( ref( haclose, -1 ), 0.5 );
hahigh = max( h, max( haclose, haopen ) );
halow = min( l, min( haclose, haopen ) );
j=haclose;
// set background gradient colours
setchartbkgradientfill( paramcolor("bgtop", colordarkgrey),paramcolor("bgbottom", colorlightgrey ),paramcolor("titleblock",colorwhite));
graphxspace = 5;
//=======================================================================================================================
//=========================indicator==============================================================================================
f=atr(15);
rfsctor = wma(h-l, per);
revers = k * rfsctor;
trend = 1;
nw[0] = 0;
nw[barcount-1] = null;
for(i = 1; i < barcount-1; i++)
{
if(trend[i-1] == 1)
{
if(j < nw[i-1])
{
trend = -1;
nw = j + revers;
}
else
{
trend = 1;
if((j - revers) > nw[i-1])
{
nw = j - revers;
}
else
{
nw = nw[i-1];
}
}
}
if(trend[i-1] == -1)
{
if(j > nw[i-1])
{
trend = 1;
nw = j - revers;
}
else
{
trend = -1;
if((j + revers) < nw[i-1])
{
nw = j + revers;
}
else
{
nw = nw[i-1];
}
}
}
}
//===============system================
//plot(nw, "", iif(trend == 1, 27, 4), 4);
//buy=nw<haclose;
//sell=nw>haclose;
//sellprice=valuewhen(sell,c,1);
//buyprice=valuewhen(buy,c,1);
//buy=exrem(buy,sell);
//sell=exrem(sell,buy );
//short=sell;
//cover=buy;
//nmab= nw<haclose;
//nmas= nw>haclose;
alertif( buy, "sound c:\\windows\\media\\buy.wav", "audio alert", 1,1+1 );
alertif( sell, "sound c:\\windows\\media\\sell.wav", "audio alert", 2,1+1 );
//nma_status= writeif(nmab, "buy mode", writeif(nmas, "sell mode", "neutral"));
//nmas_col=iif(nmab, colorgreen, iif(nmas, colorred, colorlightgrey));
filter=1;
//addcolumn( nw[barcount-1], "sar", 1.2 );
//addcolumn( haclose, "ha close", 1.2 );
//addcolumn( c, "close", 1.2 );
//addtextcolumn(nma_status, "mode", 1, colorwhite, nmas_col);
//addcolumn( datetime(), "date / time", formatdatetime );
_section_end();
_section_begin("title");
if( status("action") == actionindicator )
(
title = encodecolor(colorblack)+ " - " + name() + " - " + encodecolor(colorred)+ interval(2) + encodecolor(colorblack) +
" - " + date() +" - "+"\n" +encodecolor(colorblack) +"op-"+o+" "+"hi-"+h+" "+"lo-"+l+" "+
"cl-"+c+" "+ "vol= "+ writeval(v)+"\n"+
encodecolor(colorlime)+
writeif (buy , " go long / reverse signal at "+c+" ","")+
writeif (sell , " exit long / reverse signal at "+c+" ","")+"\n"+encodecolor(colorwhite)+
writeif(sell , "total profit/loss for the last trade rs."+(c-buyprice)+"","")+
writeif(buy , "total profit/loss for the last trade rs."+(sellprice-c)+"",""));
//writeif(long and not buy, "trade : Long - entry price rs."+(buyprice),"")+
//writeif(shrt and not sell, "trade : Short - entry price rs."+(sellprice),"")+"\n"+
//writeif(long and not buy, "current profit/loss rs."+(c-buyprice)+"","")+
//writeif(shrt and not sell, "current profit/loss rs."+(sellprice-c)+"",""));
//plotshapes(iif(buy, shapesquare, shapenone),colorgreen, 0, l, offset=-40);
//plotshapes(iif(buy, shapesquare, shapenone),colorlime, 0,l, offset=-50);
//plotshapes(iif(buy, shapeuparrow, shapenone),colorwhite, 0,l, offset=-45);
//plotshapes(iif(sell, shapesquare, shapenone),colorred, 0, h, offset=40);
//plotshapes(iif(sell, shapesquare, shapenone),colororange, 0,h, offset=50);
//plotshapes(iif(sell, shapedownarrow, shapenone),colorwhite, 0,h, offset=-45);
graphxspace=5;
for(i=barcount-1;i>1;i--)
{
if(buy == 1)
{
entry = c;
sig = "buy";
sl = ref(nw,-1);
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);
bars = i;
i = 0;
}
if(sell == 1)
{
sig = "sell";
entry = c;
sl = ref(nw,-1);
tar1 = entry - (entry * .0060);
tar2 = entry - (entry * .0120);
tar3 = entry - (entry * .0220);
bars = i;
i = 0;
}
}
offset = 20;
//clr = iif(sig == "buy", colorlime, colorred);
//ssl = iif(bars == barcount-1, nw[barcount-1], ref(nw, -1));
//sl = ssl[barcount-1];
//plot(linearray(bars-offset, tar1, barcount, tar1,1), "", clr, styleline|styledots, null, null, offset);
//plot(linearray(bars-offset, tar2, barcount, tar2,1), "", clr, styleline|styledots, null, null, offset);
//plot(linearray(bars-offset, tar3, barcount, tar3,1), "", clr, styleline|styledots, null, null, offset);
messageboard = paramtoggle("message board","show|hide",1);
if (messageboard == 1 )
{
gfxselectfont( "tahoma", 13, 100 );
gfxsetbkmode( 1 );
gfxsettextcolor( colorwhite );
if ( sig =="buy")
{
gfxselectsolidbrush( colordarkgreen ); // this is the box background color
}
else
{
gfxselectsolidbrush( colordarkred ); // this is the box background color
}
pxheight = status( "pxchartheight" ) ;
xx = status( "pxchartwidth");
left = 1100;
width = 310;
x = 5;
x2 = 290;
y = pxheight;
gfxselectpen( colorgreen, 1); // broader color
gfxroundrect( x, y - 163, x2, y , 7, 7 ) ;
gfxtextout( (" amibroker trading system "),33,y-165);
gfxtextout( (" "),27,y-160);
gfxtextout( ("" + writeif(sig =="long",sig + " at ",sig + " @") + " : " + entry), 13, y-120);
//gfxtextout( ("trailing sl : " + sl + " (" + writeval(iif(sig == "sell",entry-sl,sl-entry), 2.2) + ")"), 13, y-100);
//gfxtextout( ("tgt:1 : " + tar1), 13, y -80);
//gfxtextout( ("tgt:2 : " + tar2), 13,y-60);
//gfxtextout( ("tgt:3 : " + tar3), 13,y-40);
gfxtextout( ("current profit : " + writeval(iif(sig == "buy",(c-entry),(entry-c)),2.2)+" points"), 13, y-100);;
}
_section_end();
_section_begin("background text");
c11=paramcolor("up panel",colorblack );
c12=paramcolor("dn panel",colorblack );
c13=param("fonts",20,10,30,1 );
c14=param("left-right",2.1,1.0,5.0,0.1 );
c15=param("up-down",8,1,30,1 );
miny = status("axisminy");
maxy = status("axismaxy");
lvb = status("lastvisiblebar");
fvb = status("firstvisiblebar");
pxwidth = status("pxwidth");
pxheight = status("pxheight");
gfxsetbkmode( 0 );
gfxselectfont("tahoma", 12, 500, false, false, 0);
gfxsettextcolor(colorcustom12);
gfxsettextalign( 6 );
gfxselectfont("tahoma", 15, 600, false, false, 0);
gfxsettextcolor(colorwhite);
gfxsettextalign( 6 );
gfxtextout( "ltp "+writeval(c,1.2), status("pxwidth")/c14, status("pxheight")/c15);
gfxselectfont("tahoma", 12, 400, false, false, 0);
gfxsettextcolor(colorbrightgreen);
gfxselectfont("tahoma", 12, 400, false, false, 0);
gfxsettextcolor(colorred);
gfxselectfont("tahoma", 12, 400, false, false, 0);
gfxsettextcolor(coloryellow);
gfxselectfont("tahoma", 12, 400, false, false, 0);
gfxsettextcolor(colorgreen);
pricechange=(c-ref(c,-1))*100/ref(c,-1);
changeponit=c-ref(c,-1);
vlp=param("volume lookback period",15,10,300,10);
vrg=ma(v,vlp);
st = stdev(vrg,vlp);
vp3 = vrg + 3*st;
vp2 = vrg + 2*st;;
vp1 = vrg + 1*st;;
vn1 = vrg -1*st;
vn2 = vrg -2*st;
x=param("xposn",1,0,1000,1);
y=param("yposn",1,0,1000,1);
gfxgradientrect( 1, 1, 1400, 40, colorgrey50, colordarkgrey);
gfxsetbkmode(0);
gfxselectfont( "tahoma", 16, 800, false );
gfxsettextcolor( colorgold );
gfxtextout( name(), x+100, y+10 );
gfxselectfont( "century gothic", 15, 100, false );
gfxsettextcolor( colorwhite );
gfxtextout( date(), x+600, y+10 );
gfxselectfont( "comic sans ms", 15, 500, false );
gfxsettextcolor( coloryellow );
gfxtextout( interval(2), x+275, y+10 );
gfxselectfont( "georgia", 18, 800, false );
gfxsettextcolor( colorwhite );
gfxtextout( "amibroker trading system ", x+1000, y+10 );
//------------------------------------------------------------ h, l, o, c----------------------
gfxgradientrect( 1, 40, 1400, 55, colorgrey50, colordarkgrey );
gfxsetbkmode(0);
gfxselectfont( "areal", 9, 200, false );
gfxsettextcolor( colorwhite );
gfxtextout( "open:"+writeval(o,1.2), x+100, y+40 );
gfxselectfont( "areal", 9, 200, false );
gfxsettextcolor( colorwhite );
gfxtextout( "high:"+writeval(h,1.2), x+200, y+40 );
gfxselectfont( "areal", 9, 200, false );
gfxsettextcolor( colorwhite );
gfxtextout( "low:"+writeval(l,1.2), x+300, y+40 );
gfxselectfont( "areal", 9, 200, false );
gfxsettextcolor( colorwhite );
gfxtextout( "close:"+writeval(c,1.2), x+400, y+40 );
gfxselectfont( "script mt bold", 12, 100, false );
gfxsettextcolor( colorwhite );
gfxtextout( "by amibroker trading system ", x+1000, y+39 );
//-----------------------------------------------------------valume-------------------------------
gfxselectfont( "tahoma", 9, 200, false );
gfxsettextcolor( colorwhite );
gfxtextout( "volume="+writeval(v,1.2), x+500, y+40 );
gfxselectfont( "tahoma", 9, 200, false );
gfxsettextcolor( colorlime );
gfxtextout( writeif(v>vp2,"very high",""), x+600, y+40 );
gfxselectfont( "tahoma", 9, 200, false );
gfxsettextcolor( colorlime );
gfxtextout( writeif(v>vp1," high",""), x+600, y+40 );
gfxselectfont( "tahoma", 9, 200, false );
gfxsettextcolor( colorlime );
gfxtextout( writeif(v>vrg,"above average",""), x+600, y+40 );
gfxselectfont( "tahoma", 9, 200, false );
gfxsettextcolor( colorred );
gfxtextout( writeif(v<vrg and v>vn1,"less than average",""), x+600, y+40 );
gfxselectfont( "tahoma", 9, 200, false );
gfxsettextcolor( colorred );
gfxtextout( writeif(v<vn1,"low",""), x+600, y+40 );