Amibroker ADX Barssince >> Still Learning << :(

#1
Hello programmers,

I am a slow learner please forgive this amateur question. I hope you can please assist me or guide me please.
All I am trying to do is make the PDI Range greater than MDI adx range for 10 bars or more before buy is executed. I just don't understand "barssince" or if its being used correctly. Your help would seriously be most appreciated.

range = Param("Periods", 14, 2, 200, 1 );
Plot( ADX(range), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue ), ParamStyle("ADX style", styleThick ) );
Plot( PDI(range), "+DI", ParamColor( "+DI color", colorGreen ), ParamStyle("+DI style") );
Plot( MDI(range), "-DI", ParamColor( "-DI color", colorRed ), ParamStyle("-DI style") );

adx1 = PDI(Range) > MDI(Range);
Entry = BarsSince(adx1) <= 10


buy = Entry;
 

extremist

Well-Known Member
#2
Hello programmers,

I am a slow learner please forgive this amateur question. I hope you can please assist me or guide me please.
All I am trying to do is make the PDI Range greater than MDI adx range for 10 bars or more before buy is executed. I just don't understand "barssince" or if its being used correctly. Your help would seriously be most appreciated.

range = Param("Periods", 14, 2, 200, 1 );
Plot( ADX(range), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue ), ParamStyle("ADX style", styleThick ) );
Plot( PDI(range), "+DI", ParamColor( "+DI color", colorGreen ), ParamStyle("+DI style") );
Plot( MDI(range), "-DI", ParamColor( "-DI color", colorRed ), ParamStyle("-DI style") );

adx1 = PDI(Range) > MDI(Range);
Entry = BarsSince(adx1) <= 10


buy = Entry;
just change " Entry = BarsSince(adx1) <= 10;" line
i think u just missed semicolon at the end.

Enjoy...
 

mastermind007

Well-Known Member
#3
I think you would need

Code:
adx1 = Cross(PDI(Range), MDI(Range));
Entry = BarsSince(adx1) <= 10;
As extremist already pointed out, you had missed one semi colon on line defining Entry variable.
 

Romeo1998

Well-Known Member
#4
Dear friend,
use this code :)
The yellow arrow 0n chart is when PDI crosses MDI from below :)
and the red arrow is on the 10th bar after the cross :)
Code:
_SECTION_BEGIN("ADX");
SetChartOptions(0,0,0);
range = Param("Periods", 14, 2, 200, 1 );
Plot( ADX(range), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue ), ParamStyle("ADX style", styleThick ) );
Plot( PDI(range), "+DI", ParamColor( "+DI color", colorGreen ), ParamStyle("+DI style") );
Plot( MDI(range), "-DI", ParamColor( "-DI color", colorRed ), ParamStyle("-DI style") );

adx1 = Cross (PDI(range) , MDI(range));
Entry = Ref (adx1,-10);

buy = Entry;

Plotshapes(IIf (adx1,shapeUpArrow,shapeNone),colorYellow,0,adx1,20,0);
Plotshapes(IIf (entry,shapeUpArrow,shapeNone),colorred,0,entry,20,0);
_SECTION_END();
 

Similar threads