Simple Adx afl for amibroker..

guptak03

Well-Known Member
#1
Hello TJ friend's with the help of subroto ji (Sr114),we have created a afl on amibroker default adx with buy and sell arrows and little modification ..so test this live and please give us feed backs and suggestion's .........



_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
ParamColor("BgBottom", colorDarkGrey),ParamColor("TitleBack",colorGrey40) );
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"Price",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
grid_day = IIf(Day()!=Ref(Day(),-1),1,0);
Plot(grid_day,"",31,styleHistogram|styleDots|styleNoLabel|styleOwnScale);
_SECTION_END();


_SECTION_BEGIN("Custom ADX settings");

range = Param("ADX Range", 14, 2, 200, 1 );

pd=PDI(range);
md=MDI(range);

a=Cross(pd,md);
b=Cross(md,pd);

a=ExRem(a,b);
b=ExRem(b,a);

col=IIf(a,ColorRGB(0,100,0),ColorRGB(100,0,0));

Plot(a,"",col,styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,1,0,0);
Plot(b,"",col,styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,1,0,0);

Buy =Short= a AND (H>O );//AND O!=H);
Sell=Cover= b AND (L<O); //AND O!=L);

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Buy=Ref(Buy,-1);
Sell=Ref(Sell,-1);

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), 51, layer = 0,yposition = Low, offset = -20);
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), 42, layer = 0, yposition = High, offset = -20); //shapeSmallCircle

GraphXSpace=10;

_SECTION_END();

_SECTION_BEGIN("Title");

Title =
EncodeColor(colorWhite)+ Title = Name () + " | "
+EncodeColor(33) + Date() +" | " + "\n "
+EncodeColor(colorBrightGreen)+ "Op : "+ EncodeColor(colorWhite)+ O + " | "
+EncodeColor(colorBrightGreen)+ "Hi : "+ EncodeColor(colorWhite)+ H + " | "
+EncodeColor(colorBrightGreen)+ "Lo : "+ EncodeColor(colorWhite)+ L + " | "
+EncodeColor(colorBrightGreen)+ "Cls : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
+EncodeColor(colorBrightGreen)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
+EncodeColor(colorBrightGreen)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
+EncodeColor(colorBrightGreen)+ ") | \nVolume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1.0)+ "\n";

_SECTION_END();
 

sr114

Well-Known Member
#2
Hello TJ friend's with the help of subroto ji (Sr114),we have created a afl on amibroker default adx with buy and sell arrows and little modification ..so test this live and please give us feed backs and suggestion's .........

modified afl

_SECTION_BEGIN("Background_Setting - ");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
ParamColor("BgBottom", colorDarkGrey),ParamColor("TitleBack",colorGrey40));
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"Price",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
grid_day = IIf(Day()!=Ref(Day(),-1),1,0);
Plot(grid_day,"",31,styleHistogram|styleDots|styleNoLabel|styleOwnScale);
_SECTION_END();


_SECTION_BEGIN("Custom ADX settings");

range = Param("ADX Range", 14, 2, 200, 1 );
no=Param("TSL val",5,2,25,1);
fc=Param("tgt fct",0.004,0.0025,1,0.01);


pd=PDI(range);
md=MDI(range);

a=Cross(pd,md);
b=Cross(md,pd);

a=ExRem(a,b);
b=ExRem(b,a);

col=IIf(a,ColorRGB(0,100,0),ColorRGB(100,0,0));

//Plot(a,"",col,styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,1,0,0);
//Plot(b,"",col,styleHistogram|styleDashed|styleOwnScale|styleNoLabel,0,1,0,0);

function TBR(no)
{
dres=HHV(H,no);
dsup=LLV(L,no);
davd=IIf(H>Ref(dres,-1),1,IIf(L<Ref(dsup,-1),-1,0));
davn=ValueWhen(davd!=0,davd,1);
dtsl1=IIf(davn==1,dsup,dres);
return dtsl1;
}

dtsl=TBR(no);


Buy = a AND (H>O );//AND O!=H);
Sell= b AND (L<O); //AND O!=L);

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);


SellPrice=ValueWhen(Sell,O,1);
BuyPrice=ValueWhen(Buy,O,1);

Buy=Ref(Buy,-1); // buy at the open of next bar of the signal
Sell=Ref(Sell,-1); // sell at the open of next bar of the signal

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), 51, layer = 0,yposition = Low, offset = -20);
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), 42, layer = 0, yposition = High, offset = -20); //shapeSmallCircle

Plot(dtsl, "",colorGrey40, styleLine);// trail sl added

dist = 1.5*ATR(8);

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "" + C[ i ], i, L[ i ] - dist, colorBrightGreen); // alteration - C instead of H/L
if( Sell ) PlotText( "" + C[ i ], i, H[ i ] + dist, colorOrange);
}

for (i=BarCount-1; i>1; i--) {
if (Buy == 1)
{
entry = O;
sig = "BUY";
sl = dtsl;
tar1 = entry + (entry * fc);
tar2 = entry + (entry * 2*fc);
bars = i;
i = 0;
}

if (Sell == 1)
{
sig = "SELL";
entry = O;
sl = dtsl;
tar1 = entry - (entry * fc);
tar2 = entry - (entry * 2*fc);
bars = i;
i = 0;
}
}
GraphXSpace=10;

_SECTION_END();

_SECTION_BEGIN("Title");

Title =EncodeColor(colorYellow) + " ADX x~OVER " + "\n"
+EncodeColor(colorWhite)+ Name () + " | "
+EncodeColor(33) + Date() + "\n "
+EncodeColor(colorWhite)+ "Op : "+ EncodeColor(colorWhite)+ O + " | "
+EncodeColor(colorWhite)+ "Hi : "+ EncodeColor(colorWhite)+ H + " | "
+EncodeColor(colorWhite)+ "Lo : "+ EncodeColor(colorWhite)+ L + " | "
+EncodeColor(colorWhite)+ "Cls : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorOrange))+ C + " | "
+EncodeColor(colorWhite)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorOrange)) + WriteVal(C-Ref(C,-1))+" Rs."
+EncodeColor(colorWhite)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
+EncodeColor(colorWhite)+ ")\nVolume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorOrange))+ WriteVal(V,1.0)+ "\n\n"
+EncodeColor(colorWhite)+ "Tgt1 : Rs "+ EncodeColor(colorWhite)+tar1 + "\n "
+EncodeColor(colorWhite)+ "Tgt2 : Rs "+ EncodeColor(colorWhite)+tar2 + "\n\n "
+EncodeColor(colorWhite)+ "Trail SL : Rs "+ EncodeColor(colorWhite)+ dtsl ;


_SECTION_END();


screen shot


rgds
subroto
 
Last edited:

guptak03

Well-Known Member
#3
sir cant we have a extra function as exit @ tgt 1 and rest hold for tgt 2 or for reverse which will be very helpful for algotrading...
 

sr114

Well-Known Member
#5
could u please modify the buy sell condition :

buy : adx and +di both are above 25
sell : adx and -di both are above 25

and adx below : not in trade and relax or wait for signal
Velmont

ask Guptaji for the rules of adx
this is his idea - i only wrote the code

sorry i cant help here - if u have ur rules - then it can be implemented

rgds
subroto
 

sr114

Well-Known Member
#6
final screenshot of the afl



also to Guptaji - did u go thru Velmont's posting? what will be ur response abut the query?

rgds
subroto
 
Last edited:

guptak03

Well-Known Member
#7
als to Guptaji - did u go thru Velmont's posting? what will be ur response abut the query?

rgds
subroto



sir i dont have any knowledge on afl writing, so i request you to help velmont ji and post the afl the feature's which i may missing..:thumb:
 
#9
Equivolume chart

Hi everyone,

I have attached a file. I have the upper indicator for that example. I am hoping that some one can code the bottom indicator.

The upper chart's code was downloaded from the AB site, written by Aron Pipa. He uses gfx rectangles to create the chart, which incorporates OHLC together with volume, resulting in the various width boxes.

I would be grateful if anyone can use the coding from the upper chart minus the OHLC.

Hope the attachment explains this better that I am.

Thanks,
Ian
 
Last edited:

Similar threads