// Downloaded From https://www.WiseStockTrader.com ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Heiken Ashi is a good and powerful indicator. // // Usage: // // 1. When the trend is up, focus on candle’s body. Whenever the body become smaller, it indicates weakening. // // 2. When the trend is down, focus on the candle’s shadow. Whenever the shadow become longer, it indicates 2 signal : continuation or reversal. // // Combine it with your other favorit indicator to get the best result. // // Hope this can be helpful. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// _SECTION_BEGIN("Chart"); SetChartOptions(0,chartShowArrows|chartShowDates); SetChartBkColor(ParamColor("Outer Panel",colorDarkGrey)); SetChartBkGradientFill(ParamColor("Upper Chart",colorCustom2),ParamColor("Lower Chart",colorDarkGrey)); GraphXSpace=Param("GraphXSpace",5,-10,25,1); _SECTION_END(); _SECTION_BEGIN("Heikin-Ashi"); global MAType; global MAName; procedure MAList(type) { chList = ParamList("Type", List = "1 - EMA, 2 - WMA, 3 - DEMA, 4 - WILDERS", type-1); for( i=0; i<5; i++) { if( StrExtract(List, i) == chList ) MAType = i+1; } MAName = WriteIf(MAType == 1,"EMA", WriteIf(MAType == 2,"WMA", WriteIf(MAType == 3,"DEMA", WriteIf(MAType == 4,"WILDERS","")))); } MAList(3); // Type of Moving Average to use in HA calculation ( Choose via Properties ) procedure MAFormula(array,per,type) { CallFormula = IIf(type == 1, EMA(array,Per), IIf(type == 2, WMA(array,Per), IIf(type == 3,DEMA(array,Per), IIf(type == 4,Wilders(array,Per),Null)))); return CallFormula; } per1=Param("MA1 period",6,1,10); per2=Param("MA2 period",2,1,10); mO=MAFormula(O,per1,MAType); mH=MAFormula(H,per1,MAType); mL=MAFormula(L,per1,MAType); mC=MAFormula(C,per1,MAType); HaClose1 = IIf(BarIndex()>0,(MO+MH+ML+MC)/4,Close); HaOpen1 = IIf(BarIndex()>0,AMA( Ref( HaClose1, -1 ), 0.5 ),Open); HaClose=EMA(HaClose1,per2); HaOpen=EMA(HaOpen1,per2); HaHigh = Max( mH, Max( HaClose, HaOpen ) ); HaLow = Min(mL, Min( HaClose, HaOpen ) ); barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed); PlotOHLC(HaOpen,HaHigh,HaLow,HaClose,"Price", barcolor, styleCandle); //HA Signal Generation stochup= StochK()>StochD() ; MACDup= MACD()>Signal() ; Hist= MACD()-Signal() ; Histup= Hist>Ref(Hist,-1) ; HAup= HaClose>=HaOpen ; BuyHa= HaClose>=HaOpen ; SellHa= HaClose