heiken ashi with adx cloud

bunti_k23

Well-Known Member
#1
hello guys i found something plz chk it and give me review whether it is bakwaas or gud..


// Supertrend - Translated from Kolier MQ4
// see: http://kolier.li/indicator/kolier-supertrend-indi
// translation in Amibroker AFL code by E.M.Pottasch, 2011

procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
{
global buffer_line_down;
global buffer_line_up;
buffer_line_down = Null;
buffer_line_up = Null;

PHASE_NONE = 0;

PHASE_BUY = 1;
PHASE_SELL = -1;

phase=PHASE_NONE;
band_upper = 0;band_lower = 0;

for(i = ATR_Period + 1; i < BarCount; i++)
{
band_upper = CalcPrice + ATR_Multiplier * tr;
band_lower = CalcPrice - ATR_Multiplier * tr;

if(phase==PHASE_NONE)
{
buffer_line_up = CalcPrice;
buffer_line_down = CalcPrice;
}
if(phase!=PHASE_BUY && Close>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
{
phase = PHASE_BUY;
buffer_line_up = band_lower;
buffer_line_up[i-1] = buffer_line_down[i-1];
}
if(phase!=PHASE_SELL && Close<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
{
phase = PHASE_SELL;
buffer_line_down = band_upper;
buffer_line_down[i-1] = buffer_line_up[i-1];
}
if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
{
if(band_lower>buffer_line_up[i-1])
{
buffer_line_up = band_lower;
}
else
{
buffer_line_up = buffer_line_up[i-1];
}
}
if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
{
if(band_upper<buffer_line_down[i-1])
{
buffer_line_down = band_upper;
}
else
{
buffer_line_down = buffer_line_down[i-1];
}
}
}
}

SetBarsRequired(sbrAll,sbrAll);
//Buy = trend==1 AND trend1==1 ;
//Short=trend==-1 AND trend1==-1 ;

TrendMode = ParamToggle("TrendMode","Off|On",1);
ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
ATR_Period = Param( "ATR_Period",5,1,20,1);
tr = ATR(ATR_Period);

CalcPrice = (H+L)/2;
calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);

SetChartOptions(0,chartShowDates);

Plot(buffer_line_up,"\ntu",ColorRGB(28,134,238),styleThick);
Plot(buffer_line_down,"\ntd",ColorRGB(205,51,51),styleThick);

Plot( 2,"",IIf(buffer_line_up,colorGreen,colorBlack),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
Plot( 4,"",IIf(buffer_line_down,colorRed,colorBlack),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );




/*
Heikin-Ashi(Koma-Ashi) with Moving Average Type
*/
SetChartOptions(2, chartWrapTitle);

// Calculate Moving Average
MAPeriod = Param("MA Period", 15, 1, 100);
MAOpen = EMA(Open, MAPeriod);
MAHigh = EMA(High, MAPeriod);
MALow = EMA(Low, MAPeriod);
MAClose = EMA(Close, MAPeriod);

HaClose = (MAOpen + MAHigh + MALow + MAClose) / 4;
HaOpen = AMA(Ref(HaClose, -1), 0.5);

// for graph collapse
for(i = 0; i <= MAPeriod; i++) HaClose = Null;
/*
// same
// HaOpen = (Ref(HaOpen, -1) + Ref(HaClose, -1)) / 2;
HaOpen[ 0 ] = HaClose[ 0 ];
for(i = 1; i < BarCount; i++) {
HaOpen = (HaOpen[i - 1] + HaClose[i - 1]) / 2;
}
*/

HaHigh = Max(MAHigh, Max(HaClose, HaOpen));
HaLow = Min(MALow, Min(HaClose, HaOpen));

// outs comments
"BarIndex = " + BarIndex();
"Open = " + Open;
"High = " + High;
"Low = " + Low;
"Close = "+ Close;
"HaOpen = " + HaOpen;
"HaHigh = " + HaHigh;
"HaLow = " + HaLow;
"HaClose = "+ HaClose;

// Plot graphs
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} HaOpen %g, HaHigh %g,
HaLow %g, HaClose %g (%.1f%%) {{VALUES}}",
HaOpen, HaHigh, HaLow, HaClose, SelectedValue(ROC( HaClose, 1))));
PlotOHLC(HaOpen, HaHigh, HaLow, HaClose, _DEFAULT_NAME(), ParamColor("Color",
colorBlack), styleCandle);

_SECTION_BEGIN("Colour Tap");
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
_SECTION_END();


_SECTION_BEGIN("supp");
("Price");
RSIperiod = 15; // Param("RSI p",3,14,30,1);
Percent = 5; // Param("ZIG %",8,9,15,1);
EMAperiod = 5; //Param("EMA p",4,5,10,1);
HHVperiod = 8; //Param("HHV p",3,5,10,1);
NumLine = 2; //Param("Num Lines",3,1,20,1);

Base = DEMA(RSI(RSIperiod),EMAperiod);

GraphXSpace=0.5;


for( i = 1; i <= numline; i++ )
{
ResBase = LastValue(Peak(Base,Percent,i));
SupBase = LastValue(Trough(Base,Percent,i));
Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleLine);
Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleLine);
}

_SECTION_END();

-------------------------------------------------------------------


below is the adx cloud afl apply both the afl s on chart and observe it


P1 = Param("Period",10,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 ), colorGreen, colorRed );
Plot( MyADX,"ADX",col, styleNoTitle | styleLine | styleThick);
Plot( MyPDI,"+DI",colorGreen, styleNoTitle | styleLine | styleThick);
Plot( MyMDI,"-DI",colorBlue, styleNoTitle | styleLine | styleThick);


PlotOHLC(MyPDI,MyPDI,MyMDI,MyMDI,"",IIf(MyPDI>MyMDI,colorAqua,colorOrange),styleCloud);

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

Similar threads