This i post a half year ago
Here i have made a kind of MACD indicator from the halftrend indicator from the Great NICOLAS, after the improvement from him , I want to shared with everybody.
The histogram is made from the difference of 2 HalfTrend indicator (one long and one short period), then a signal line, built with an average of 6 periods of the histogram values is added.
This was not the only one i made from the halftrend indicator, i made another one, called halftrend Dmi indicator, but i was not sure of it was usebel, but after more observation , i decided to share it with everyone.
The halftrend code is from Nicolas, like above, i changed it a littll bit 🙂
Trades signals are the same like a normal DMI: long position when the HtDmiplus is crosses HtDmimin and above the zero line, short when the HtDmimin crosses HtDmiplus and above the zero line. The color changing is a early warning , you can close the trade of look at the normal DMI of look at the Halftrend indi for conformation.
Short signal when the HtDmimin crosses HtDmiplus and HtDmimin is above the zero level
Long signal when HtDmiplus is crosses HtDmimin and above the zero level
LOOK at COLOR CHANGING very important !!!!!!!!!!!!!!!!
Greetings to everyone and happy trading to all. Lucassen
//10.03.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//Amplitude1 = 2
//Amplitude2 = 6
//Amplitude3 = 30
// -- HL #1
lowpricei1 = Lowest[Amplitude1](low)
highpricei1 = Highest[Amplitude1](high)
lowma1 = average[Amplitude1](low)
highma1 = average[Amplitude1](high)
if barindex>Amplitude1 then
if(nexttrend1=1) then
maxlowprice1=Max(lowpricei1,maxlowprice1)
if(highma1<maxlowprice1 and Close<Low[1]) then
trend1=1.0
nexttrend1=0
minhighprice1=highpricei1
endif
endif
if(nexttrend1=0) then
minhighprice1=Min(highpricei1,minhighprice1)
if(lowma1>minhighprice1 and Close>High[1]) then
trend1=0.0
nexttrend1=1
maxlowprice1=lowpricei1
endif
endif
if(trend1=0.0) then
if(trend1[1]<>0.0) then
up1=down1[1]
else
up1=Max(maxlowprice1,up1[1])
endif
down1=0.0
else
if(trend1[1]<>1.0) then
down1=up1[1]
else
down1=Min(minhighprice1,down1[1])
endif
up1=0.0
endif
endif
// -- HL #2
lowpricei2 = Lowest[Amplitude2](low)
highpricei2 = Highest[Amplitude2](high)
lowma2 = average[Amplitude2](low)
highma2= average[Amplitude2](high)
if barindex>Amplitude2 then
if(nexttrend2=1) then
maxlowprice2=Max(lowpricei2,maxlowprice2)
if(highma2<maxlowprice2 and Close<Low[1]) then
trend2=1.0
nexttrend2=0
minhighprice2=highpricei2
endif
endif
if(nexttrend2=0) then
minhighprice2=Min(highpricei2,minhighprice2)
if(lowma2>minhighprice2 and Close>High[1]) then
trend2=0.0
nexttrend2=1
maxlowprice2=lowpricei2
endif
endif
if(trend2=0.0) then
if(trend2[1]<>0.0) then
up2=down2[1]
else
up2=Max(maxlowprice2,up2[1])
endif
down2=0.0
else
if(trend2[1]<>1.0) then
down2=up2[1]
else
down2=Min(minhighprice2,down2[1])
endif
up2=0.0
endif
endif
if up2>0 then
halftrend2 = up2
else
halftrend2 = down2
endif
// -- HL #3
lowpricei3 = Lowest[Amplitude3](low)
highpricei3 = Highest[Amplitude3](high)
lowma3 = average[Amplitude3](low)
highma3= average[Amplitude3](high)
if barindex>Amplitude3 then
if(nexttrend3=1) then
maxlowprice3=Max(lowpricei3,maxlowprice3)
if(highma3<maxlowprice3 and Close<Low[1]) then
trend3=1.0
nexttrend3=0
minhighprice3=highpricei3
endif
endif
if(nexttrend3=0) then
minhighprice3=Min(highpricei3,minhighprice3)
if(lowma3>minhighprice3 and Close>High[1]) then
trend3=0.0
nexttrend3=1
maxlowprice3=lowpricei3
endif
endif
if(trend3=0.0) then
if(trend3[1]<>0.0) then
up3=down3[1]
else
up3=Max(maxlowprice3,up3[1])
endif
down3=0.0
else
if(trend3[1]<>1.0) then
down3=up3[1]
else
down3=Min(minhighprice3,down3[1])
endif
up3=0.0
endif
endif
if up3>0 then
halftrend3 = up3
else
halftrend3 = down3
endif
return (halftrend2 - halftrend3),average[6] (halftrend2 - halftrend3)