Skip to main content

Trend All About for Amibroker (AFL)

morgen about 16 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    oscillator, amibroker

It’s about Trend!
You can try also Buy/Sell section.

Indicator / Formula

Copy & Paste Friendly

//TREND ALL ABOUT

/*-----------------------------------------------------------
MTR Investors Group - www.MTRIG.com

Color MACD Histogram Bars. Use on weekly chart to determine
market trend. See Elder "Come into my trading room"
-------------------------------------------------------------*/

r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
Hist = ml-sl;

MACUP = Hist > Ref(Hist,-1) AND Hist>0;
MACDN = Hist < 0 ;
BarColor  = IIf(MACUP,colorLime,IIf(MACDN,colorCustom12,colorAqua));

//Plot( Hist, "MACD Histogram", ParamColor("Histogram color", colorBlack ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );
Plot( Hist, "MACD Histogram", BarColor  , styleHistogram |styleThick|styleOwnScale);
//Plot(0, "0", colorBlack );
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


//Trend Following Systems DO NOT work when ADX is Below 20 - Tech Analysis A-Z; page 120

P1 = Param("Period",14,0,100,1);

MyPDI= PDI(P1);//Positive Directional Indicator

MyMDI= MDI(P1);//Negative Directional Indicator (Minus)

MyADX= ADX(P1);//Average Directional Movement Index

//Green ADX Line=Rising; Red ADX Line=Falling

col = IIf( MyADX > Ref( MyADX, -1 ), colorSeaGreen, colorAqua );

Plot( MyPDI,"+DI",colorLime, styleLine |styleThick);

Plot( MyMDI,"-DI",colorOrange, styleLine |styleThick);

Plot( MyADX,"ADX",col, styleDots );

Title=Name()+ " " + Date() + " Price: " + C + EncodeColor(colorBlack) +"  ADX" + WriteVal( MyADX )+ EncodeColor(colorGreen) + " 
      +DMI" + WriteVal( MyPDI )+ EncodeColor(colorRed) + "  -DMI" + WriteVal( MyMDI );

//BUY/SELL ;try to activate this, AFTER disactivate the other "plot lines" and simply drag-and-drop on the pricechart

//Buy=MAcup AND mypdi>mymdi AND ADX()<40;
//Sell=MACDn ;

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

//PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone),colorAqua,0,L,Offset=-20);
//PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorCustom12,0,H,Offset=-20);

3 comments

2. morgen
about 16 years ago

To mahesh.aranake
See the formula in Buy/Sell section:
1)Disactivate “plot lines” with “//”;
2)Activate Buy/Sell to see like that:

Buy=MAcup AND mypdi>mymdi AND ADX()<40;
Sell=MACDn ;

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

So, without “//”!

about 16 years ago

Thank you Morgen for the prompt assistance – it works fine and also gave me some more knowledge of AFL syntax

Leave Comment

Please login here to leave a comment.