macd and adx .. a deadly combo ...

amitrandive

Well-Known Member
#22
AFL posted

http://www.traderji.com/amibroker/90119-simple-coding-help-no-promise-146.html#post959978

Code:
range = Param("ADX Periods", 10, 2, 200, 1 );
r1 = Param( "Macd Fast avg", 12, 2, 200, 1 );
r2 = Param( "Macd Slow avg", 26, 2, 200, 1 );
r3 = Param( "Macd Signal avg", 9, 2, 200, 1 ); 
myADX = ADX(range);
myMacd = MACD(r1,r2);
mySignal = Signal(r1,r2,r3);

//1. Buy when MACD gives bullish Signal AND ADX is above 25 .
Buy = myMacd > mySignal AND myADX > 25;
//2. Sell when MACD gives negative Signal OR u get decent 25 points OR market is closed. 
Sell = myMacd < mySignal OR Cross(H, ValueWhen(Buy,Close)+25) OR TimeNum()>152500;
//3. Short when MACD gives bearish Signal AND ADX is above 25. 
Short = myMacd < mySignal AND myADX > 25;
//4. Cover when MACD gives bullish Signal OR u get decent 25 points OR market is closed.
Cover = myMacd > mySignal  OR Cross(ValueWhen(Short,Close)-25,L) OR TimeNum()>152500; 

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short, Cover);
Cover= ExRem(Cover,Short);
// exploration
Filter = Buy OR Short; 
AddColumn(Close, "Close", 1.2);
AddColumn(Buy, "Buy", 1.0);
AddColumn(Short, "Short",1.0);
_SECTION_END();
PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45); 
PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);
PlotShapes(Sell*shapeHollowDownArrow,colorRed,0,L,-51);
PlotShapes(Cover*shapeHollowUpArrow,colorBlue,0,H,-51);
 

amitrandive

Well-Known Member
#25
I am not able to see the chart if i post the afl code

it is showing very blank page only.

can anyone help me?
Need to drag the price on the chart.Posting the complete AFL

Code:
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
range = Param("ADX Periods", 10, 2, 200, 1 );
r1 = Param( "Macd Fast avg", 12, 2, 200, 1 );
r2 = Param( "Macd Slow avg", 26, 2, 200, 1 );
r3 = Param( "Macd Signal avg", 9, 2, 200, 1 ); 
myADX = ADX(range);
myMacd = MACD(r1,r2);
mySignal = Signal(r1,r2,r3);

//1. Buy when MACD gives bullish Signal AND ADX is above 25 .
Buy = myMacd > mySignal AND myADX > 25;
//2. Sell when MACD gives negative Signal OR u get decent 25 points OR market is closed. 
Sell = myMacd < mySignal OR Cross(H, ValueWhen(Buy,Close)+25) OR TimeNum()>152500;
//3. Short when MACD gives bearish Signal AND ADX is above 25. 
Short = myMacd < mySignal AND myADX > 25;
//4. Cover when MACD gives bullish Signal OR u get decent 25 points OR market is closed.
Cover = myMacd > mySignal  OR Cross(ValueWhen(Short,Close)-25,L) OR TimeNum()>152500; 

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short, Cover);
Cover= ExRem(Cover,Short);
// exploration
Filter = Buy OR Short; 
AddColumn(Close, "Close", 1.2);
AddColumn(Buy, "Buy", 1.0);
AddColumn(Short, "Short",1.0);
_SECTION_END();
PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45); 
PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);
PlotShapes(Sell*shapeHollowDownArrow,colorRed,0,L,-51);
PlotShapes(Cover*shapeHollowUpArrow,colorBlue,0,H,-51);
 
#28
Need to drag the price on the chart.Posting the complete AFL

Code:
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
range = Param("ADX Periods", 10, 2, 200, 1 );
r1 = Param( "Macd Fast avg", 12, 2, 200, 1 );
r2 = Param( "Macd Slow avg", 26, 2, 200, 1 );
r3 = Param( "Macd Signal avg", 9, 2, 200, 1 ); 
myADX = ADX(range);
myMacd = MACD(r1,r2);
mySignal = Signal(r1,r2,r3);

//1. Buy when MACD gives bullish Signal AND ADX is above 25 .
Buy = myMacd > mySignal AND myADX > 25;
//2. Sell when MACD gives negative Signal OR u get decent 25 points OR market is closed. 
Sell = myMacd < mySignal OR Cross(H, ValueWhen(Buy,Close)+25) OR TimeNum()>152500;
//3. Short when MACD gives bearish Signal AND ADX is above 25. 
Short = myMacd < mySignal AND myADX > 25;
//4. Cover when MACD gives bullish Signal OR u get decent 25 points OR market is closed.
Cover = myMacd > mySignal  OR Cross(ValueWhen(Short,Close)-25,L) OR TimeNum()>152500; 

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short, Cover);
Cover= ExRem(Cover,Short);
// exploration
Filter = Buy OR Short; 
AddColumn(Close, "Close", 1.2);
AddColumn(Buy, "Buy", 1.0);
AddColumn(Short, "Short",1.0);
_SECTION_END();
PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45); 
PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);
PlotShapes(Sell*shapeHollowDownArrow,colorRed,0,L,-51);
PlotShapes(Cover*shapeHollowUpArrow,colorBlue,0,H,-51);


Hello amit ..

Did u try and watch the scanner...???

scanner is giving stocks which are above 25 Adx and macd already crossed...

lots many stocks are getting filtered...

i feel.. we need stocks which are around 25 (Crossing 25) and macd also recently crossed..


Less stocks but Quality is good

wts ur view points..

i would ask Masterstroke suggestion also...

Thanx you
 

amitrandive

Well-Known Member
#29
Hello amit ..

Did u try and watch the scanner...???

scanner is giving stocks which are above 25 Adx and macd already crossed...

lots many stocks are getting filtered...

i feel.. we need stocks which are around 25 (Crossing 25) and macd also recently crossed..


Less stocks but Quality is good

wts ur view points..

i would ask Masterstroke suggestion also...

Thanx you
shruti

Have not used this.Maybe if we use on a higher time frame like Daily/Hourly,it make work better.
:thumb:
 

Similar threads