ADX Scanner, Exploration and Back Test

abhinkoi

Active Member
#1
Hi Seniors,

Can someone write an afl from the below mentioned conditions which can act as a scanner, explorer and backtester -

BUY when

+DI crosses DI from bottom to top
+DI crosses ADX from bottom to top

SELL when

-DI crosses +DI from bottom to top
+DI crosses ADX from top to bottom
-DI crosses ADX from bottom to top

Thanks in advance.

Cheers
Abhi
 

dhakkan

Active Member
#2
Here's the AFL :

The backtest will not work properly as buy and sell are not balanced, you can use ExRem() to balance them (I have commented them, you can uncomment ).

//////////////////////////////////////////////////////////////////////////////
// TEST ADX
_SECTION_BEGIN("ADX TEST");
range = Param("Range",14,3,60,1);

px = PDI(range);
nx = MDI(range);
ax = ADX(range);

// Buy Conditions
bcon1 = Cross(px,nx);
bcon2 = Cross(px,ax);
Buy = bcon1 OR bcon2;

// Sell Conditions
scon1 = Cross(nx,px);
scon2 = Cross(ax,px);
scon3 = Cross(nx,ax);
Sell = scon1 OR scon2 OR scon3;

// Explorer
Filter = Buy OR Sell;
AddColumn(Buy,"Buy",1);
AddColumn(Sell,"Sell",1);

// balancing buy sell
///Buy = ExRem(Buy, Sell);
//Sell = ExRem(Sell, Buy);

/// Plots
Plot(px,"+DI",colorGreen,1);
Plot(nx,"-DI",colorRed,1);
Plot(ax,"ADX",colorBlue,5);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorDarkRed);
_SECTION_END();
 

abhinkoi

Active Member
#3
Thank you very much dear...its giving the desired results but when I click on scan it gives error 2 times and then show the results.

1st error -

Plot(nx,"-DI",colorRed,1);
Plot(ax,"ADX",colorBlue,5);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBl u
---------------------------------------------------^

Error 31.
Syntax error, expecting ')' or ','

==================

2nd error -


Plot(ax,"ADX",colorBlue,5);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBl ue);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colo r
---------------------------------------------------^

Error 31.
Syntax error, expecting ')' or ','

Can you please remove these errors?
Otherwise its working fine.

Thx a million
Abhinav
 

dhakkan

Active Member
#4
Oh.. It seems there are spaces... remove them "colorBl ue" and "colo r" remove the space...
and check all the lines...
I dont know how it happened...:)

also .. you can try to check the syntax... it will give you the exact error and you can fix it.

enjoy
 

abhinkoi

Active Member
#5
Yes it worked fine. YOu hit right on the target.
Thanks a ton again.
Much appreciated...

Thx
Abhi
 

abhinkoi

Active Member
#6
Hi Dhakkan,

In order to refine my scan results I have put in some additional conditions. Could you please modify the afl according to these -


BUY when

+DI crosses DI from bottom to top
+DI crosses ADX from bottom to top but only if DI is lower than +DI

SELL when

-DI crosses +DI from bottom to top
+DI crosses ADX from top to bottom but only if DI is higher than +DI
-DI crosses ADX from bottom to top but only if +DI is lower than -DI

Thanks in advance

Cheers
Abhi
 

dhakkan

Active Member
#7
Hi Dhakkan,

In order to refine my scan results I have put in some additional conditions. Could you please modify the afl according to these -


BUY when

+DI crosses DI from bottom to top
+DI crosses ADX from bottom to top but only if DI is lower than +DI

SELL when

-DI crosses +DI from bottom to top
+DI crosses ADX from top to bottom but only if DI is higher than +DI
-DI crosses ADX from bottom to top but only if +DI is lower than -DI

Thanks in advance

Cheers
Abhi
Hi Abhi,

These are simple things, learn AFL .. it will help you, or you may end up reveling all your tricks to others..:)

Anyway's... edited the AFL and here it is....
Check if it suits your requirement or not...
/////////////////////////////////////////////////////////////////////////////////////
// TEST ADX
_SECTION_BEGIN("ADX TEST");
range = Param("Range",14,3,60,1);

px = PDI(range);
nx = MDI(range);
ax = ADX(range);

// Buy Conditions
bcon1 = Cross(px,nx);
bcon2 = Cross(px,ax) AND nx < px;
Buy = (bcon1) OR (bcon2);

// Sell Conditions
scon1 = Cross(nx,px);
scon2 = Cross(ax,px) AND nx > px;
scon3 = Cross(nx,ax) AND px < nx;
Sell = (scon1) OR (scon2) OR (scon3);

// Explorer
Filter = Buy OR Sell;
AddColumn(Buy,"Buy",1);
AddColumn(Sell,"Sell",1);

// balancing buy sell
///Buy = ExRem(Buy, Sell);
//Sell = ExRem(Sell, Buy);

/// Plots
Plot(px,"+DI",colorGreen,1);
Plot(nx,"-DI",colorRed,1);
Plot(ax,"ADX",colorBlue,5);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorDarkRed);
_SECTION_END();
 

abhinkoi

Active Member
#8
Thank you very much dear..yes its working absolutely the way I wanted it to work. You are amazing..I am in the process of learning it but till the time I get expert like you I need help and guidance from you experts in writing my mind (tricks which come to my mind). I hope you dont mind helping me and of course anyone who is seeing this thread...

If we are able to develop a strategy which can be beneficial to all it wud be a great help to the trading community.

Thanks a million for your unconditional and timely help. Much appreciated.

Thanks
Abhi
 

Similar threads