_SECTION_BEGIN("HA Looping ( no AMA() )");
///////////////////////////////////////////////////////////
// Heikin Ashi - Calculated Properly without using AMA
// JF Derzi, December 2012
HaClose[0] = (Open[0]+High[0]+Low[0]+Close[0]) / 4;
HaOpen[0] = (HaClose[0] + Open[0]) / 2;
HaHigh[0] = Max( High[0], Max( HaClose[0], HaOpen[0] ) );
HaLow[0] = Min( Low[0], Min( HaClose[0], HaOpen[0] ) );
for (i = 1; i < BarCount; i++)
{
HaClose[i] = (Open[i]+High[i]+Low[i]+Close[i]) / 4;
Haopen[i] = (HaClose[i-1] + HaOpen[i-1]) / 2;
// Here is the problem when using Arrays: Haopen always uses its own previous value
HaHigh[i] = Max( High[i], Max( HaClose[i], HaOpen[i] ) );
Halow[i] = Min( Low[i], Min( HaClose[i], HaOpen[i] ) );
}
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", colorBlack, styleCandle);
Title = Name()+" "+Date()+" Heikin Ashi -- HaOpen:"+NumToStr(HaOpen,1.2,True)+" / HaHigh:"+NumToStr(HaHigh,1.2,True)+" / HaLow:"+NumToStr(Halow,1.2,True)+" HaClose:"+NumToStr(Haclose,1.2, True);
_SECTION_END();
_SECTION_BEGIN("MA");
Periods = Param("Periods", 15, 2, 300, 1, 10 );
simpleMA = MA( HaClose, Periods );
Plot( simpleMA, "MA2", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); _SECTION_END();
_SECTION_END();
_SECTION_BEGIN("OSMA");
// osma implementation for Amibroker
// version 0.2 (c) 28th April 2011, [email protected]
FastEma=Param("Fast EMA", 12, 1 , 25, 1);
SlowEma=Param("Slow EMA", 26, 1 , 50, 1);
SignalEma=Param("Signal EMA", 9, 1 , 25, 1);
// signals
OsMA=MACD( FastEma, SlowEma )-Signal( FastEma, SlowEma, SignalEma );
// Plot removed
_SECTION_END();
_SECTION_BEGIN("Momentum");
momentum = HaClose * 100 / Ref(HaClose, -Param("Period", 10, 1, 100 ) );
// Plot removed
_SECTION_END();
_SECTION_BEGIN("RSIa");
periods = Param("Periods", 15, 1, 200, 1 );
rxRsi = RSIa( HaClose, periods);
_SECTION_END();
longCond1 = Cross(HaClose, simpleMA);
longCond2 = OsMA > 0;
longCond3 = momentum > 100;
longCond4 = rxRsi > 50;
PlotShapes(longCond1 * shapeDigit1, colorBlue, 0, HaLow - 5);
PlotShapes(longCond2 * shapeDigit2, colorBlue, 0, HaLow - 10);
PlotShapes(longCond3 * shapeDigit3, colorBlue, 0, HaLow - 15);
PlotShapes(longCond4 * shapeDigit4, colorBlue, 0, HaLow - 20);
Buy = ((HaOpen < HaClose) AND Cross(HaClose, simpleMA) AND (OsMA > 0) AND (momentum > 100) AND (rxRsi > 50));
Short = ((HaOpen > HaClose) AND Cross(HaClose, simpleMA) AND (OsMA < 0) AND (momentum < 100) AND (rxRsi < 50));
....