Page 29 of 38

Re: Trend Direction Force Index Indicators MT4

Posted: Wed Dec 13, 2023 7:44 am
by francisfinley stimpy
mrtools wrote: Wed Dec 13, 2023 5:18 am That is a non-repaint version.
Awesome thanks mate

Re: Trend Direction Force Index Indicators MT4

Posted: Sun Dec 17, 2023 8:02 pm
by smartvin
Hi
Could someone share the source file in the attached indicator? Thanks

! Trend direction + force index avgs (multi symbol + mtf + alerts + btn).ex4

Re: Trend Direction Force Index Indicators MT4

Posted: Sun Dec 17, 2023 10:14 pm
by Jimmy
smartvin wrote: Sun Dec 17, 2023 8:02 pm Hi
Could someone share the source file in the attached indicator? Thanks

! Trend direction + force index avgs (multi symbol + mtf + alerts + btn).ex4
Hi and welcome to the site. Source code requests aren't allowed here simply because a lot of open-source files have ended up being pinched and sold in the past.

We ask you to respect our coders choice to protect their files as listed on our rules page.

Thanks for understanding and hope to see you around.

Re: Trend Direction Force Index Indicators MT4

Posted: Fri Dec 29, 2023 8:45 pm
by moey_dw
mrtools wrote: Fri Nov 10, 2023 4:44 amOn/off button added to this a tad different version.
Good afternoon Mrtools.... sorry I know its the holidays but I am banging my head against the wall trying to clone this TDFI without success 😥

Please can you make a TDFI like this? My reason is because this TDFI version gives more signals where traditional TDFI misses out and also uses JMA.

Code: Select all

//@version=3
study("Trend Direction Force Index", shorttitle="TDFI")

trendPeriod = input(title="Trend Period", defval=20)
maType = input(title="MA Type", defval="JMA",
			 options=["DEMA",
			 "EMA",
			 "HMA",
			 "JMA",
			 "LSMA",
			 "PWMA",
			 "SMMA",
			 "SMA",
			 "SSF2",
			 "SWMA",
			 "TEMA",
			 "TMA",
			 "VWMA",
			 "WMA",
			 "ZLEMA"])
maPeriod = input(title="MA Period", type=integer, defval=8)
triggerUp = input(title="TriggerUp", defval=0.05)
triggerDown = input(title="TriggerDown", defval=-0.05)
showZeroCrosses = input(title="Show zero cross signals", defval=true)
showLineCrosses = input(title="Show level cross signals", defval=false)

PI = 2 * asin(1)
mma = ema(close, trendPeriod)
smma = ema(mma, trendPeriod)

impetmma = change(mma)
impetsmma = change(smma)
divma = abs(mma - smma) / syminfo.mintick
averimpet = avg(impetmma, impetsmma) / (2 * syminfo.mintick)

tdfRaw = divma * pow(averimpet, 3)
tdfAbsRaw = abs(tdfRaw)

for i = 1 to 3 * trendPeriod - 1
    cand = abs(nz(tdfRaw[i]))
    tdfAbsRaw := cand > tdfAbsRaw ? cand : tdfAbsRaw

ratio = tdfRaw / tdfAbsRaw
smooth = na

//------------------------------------------------------------------------------
// Super Smoother

_ssf2(src, length) =>
	arg = sqrt(2) * PI / length
	a1 = exp(-arg)
	b1 = 2 * a1 * cos(arg)
	c2 = b1
	c3 = -pow(a1, 2)
	c1 = 1 - c2 - c3
	ssf = 0.0
	ssf := c1 * src + c2 * nz(ssf[1], nz(src[1], src)) + c3 * nz(ssf[2], nz(src[2], nz(src[1], src)))

smooth := maType == "SSF2" ? _ssf2(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// DEMA

_dema(src, length) =>
	ema1 = ema(src, length)
	ema2 = ema(ema1, length)
	2 * ema1 - ema2

smooth := maType == "DEMA" ? _dema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// EMA

smooth := maType == "EMA" ? ema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// HMA, Hull

_hma(src, length) =>
	wma(2 * wma(src, length / 2) - wma(src, length), round(sqrt(length)))

smooth := maType == "HMA" ? _hma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// LSMA, Least Squares

smooth := maType == "LSMA" ? linreg(ratio, maPeriod, 0) : smooth

//------------------------------------------------------------------------------
// PWMA, Parabolic Weighted

_pwma(src, length) =>
	sum = 0.0
	weightSum = 0.0
	for i = 0 to length - 1
		weight = pow(length - i, 2)
		sum := sum + nz(src[i]) * weight
		weightSum := weightSum + weight
	sum / weightSum

smooth := maType == "PWMA" ? _pwma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// SMMA

smooth := maType == "SMMA" ? rma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// SMA

smooth := maType == "SMA" ? sma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// SWMA

_swma(src, length) =>
	sum = 0.0
	weightSum = 0.0
	for i = 0 to length - 1
		weight = sin(i * PI / (length + 1))
		sum := sum + nz(src[i]) * weight
		weightSum := weightSum + weight
	sum / weightSum

smooth := maType == "SWMA" ? _swma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// TEMA

_tema(src, length) =>
	ema1 = ema(src, length)
	ema2 = ema(ema1, length)
	ema3 = ema(ema2, length)
	3 * (ema1 - ema2) + ema3

smooth := maType == "TEMA" ? _tema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// TMA

_tma(src, length) =>
	sma(sma(src, ceil(length / 2)), floor(length / 2) + 1)

smooth := maType == "TMA" ? _tma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// VWMA

smooth := maType == "VWMA" ? vwma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// WMA

smooth := maType == "WMA" ? wma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// ZLEMA

_zlema(src, length) =>
	lag = length <= 2 ? 1 : floor((length - 1) / 2)
	ema(src + (src - nz(src[lag])), length)

smooth := maType == "ZLEMA" ? _zlema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// JMA

_jma(src, length) =>
	alpha = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)
	out = 0.0
	e0 = 0.0
	e0 := (1 - alpha) * src + alpha * nz(e0[1])
	e1 = 0.0
	e1 := (1 - alpha) * (src - e0) + alpha * nz(e1[1])
	e2 = 0.0
	e2 := pow(1 - alpha, 2) * (e0 + e1 - nz(out[1])) + pow(alpha, 2) * nz(e2[1])
	out := e2 + nz(out[1])

smooth := maType == "JMA" ? _jma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------

tdf = tdfAbsRaw > 0 ? max(min(na(smooth) ? ratio : smooth, 1), -1) : 0.0

tdfColor = tdf > triggerUp ? #0ebb23 : tdf < triggerDown ? red : gray
plot(tdf, linewidth=2, color=tdfColor, transp=0)
hline(triggerUp, title="Trigger Up", linestyle=dotted)
hline(triggerDown, title="Trigger Down", linestyle=dotted)

plotshape(crossover(tdf, 0) and showZeroCrosses ? 0 : na, title="Zero Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0)
plotshape(crossunder(tdf, 0) and showZeroCrosses ? 0 : na, title="Zero Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0)

plotshape(crossover(tdf, triggerUp) and showLineCrosses ? triggerUp : na, title="Upper Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0)
plotshape(crossunder(tdf, triggerUp) and showLineCrosses ? triggerUp : na, title="Upper Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0)
plotshape(crossover(tdf, triggerDown) and showLineCrosses ? triggerDown : na, title="Lower Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0)
plotshape(crossunder(tdf, triggerDown) and showLineCrosses ? triggerDown : na, title="Lower Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0)

alertcondition(crossover(tdf, 0), title="Cross zero line up", message="TDF crossed zero line up!")
alertcondition(crossunder(tdf, 0), title="Cross zero line down", message="TDF crossed zero line down!")
alertcondition(crossover(tdf, triggerUp), title="Cross upper line up", message="TDF crossed upper line up!")
alertcondition(crossunder(tdf, triggerUp), title="Cross upper line down", message="TDF crossed upper line down!")
alertcondition(crossover(tdf, triggerDown), title="Cross lower line up", message="TDF crossed lower line up!")
alertcondition(crossunder(tdf, triggerDown), title="Cross lower line down", message="TDF crossed lower line down!")
I think it will be such a good addition to our site what do you think of it?

Re: Trend Direction Force Index Indicators MT4

Posted: Sat Dec 30, 2023 1:02 am
by mrtools
moey_dw wrote: Fri Dec 29, 2023 8:45 pm Good afternoon Mrtools.... sorry I know its the holidays but I am banging my head against the wall trying to clone this TDFI without success 😥

Please can you make a TDFI like this? My reason is because this TDFI version gives more signals where traditional TDFI misses out and also uses JMA.

Code: Select all

//@version=3
study("Trend Direction Force Index", shorttitle="TDFI")

trendPeriod = input(title="Trend Period", defval=20)
maType = input(title="MA Type", defval="JMA",
			 options=["DEMA",
			 "EMA",
			 "HMA",
			 "JMA",
			 "LSMA",
			 "PWMA",
			 "SMMA",
			 "SMA",
			 "SSF2",
			 "SWMA",
			 "TEMA",
			 "TMA",
			 "VWMA",
			 "WMA",
			 "ZLEMA"])
maPeriod = input(title="MA Period", type=integer, defval=8)
triggerUp = input(title="TriggerUp", defval=0.05)
triggerDown = input(title="TriggerDown", defval=-0.05)
showZeroCrosses = input(title="Show zero cross signals", defval=true)
showLineCrosses = input(title="Show level cross signals", defval=false)

PI = 2 * asin(1)
mma = ema(close, trendPeriod)
smma = ema(mma, trendPeriod)

impetmma = change(mma)
impetsmma = change(smma)
divma = abs(mma - smma) / syminfo.mintick
averimpet = avg(impetmma, impetsmma) / (2 * syminfo.mintick)

tdfRaw = divma * pow(averimpet, 3)
tdfAbsRaw = abs(tdfRaw)

for i = 1 to 3 * trendPeriod - 1
    cand = abs(nz(tdfRaw[i]))
    tdfAbsRaw := cand > tdfAbsRaw ? cand : tdfAbsRaw

ratio = tdfRaw / tdfAbsRaw
smooth = na

//------------------------------------------------------------------------------
// Super Smoother

_ssf2(src, length) =>
	arg = sqrt(2) * PI / length
	a1 = exp(-arg)
	b1 = 2 * a1 * cos(arg)
	c2 = b1
	c3 = -pow(a1, 2)
	c1 = 1 - c2 - c3
	ssf = 0.0
	ssf := c1 * src + c2 * nz(ssf[1], nz(src[1], src)) + c3 * nz(ssf[2], nz(src[2], nz(src[1], src)))

smooth := maType == "SSF2" ? _ssf2(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// DEMA

_dema(src, length) =>
	ema1 = ema(src, length)
	ema2 = ema(ema1, length)
	2 * ema1 - ema2

smooth := maType == "DEMA" ? _dema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// EMA

smooth := maType == "EMA" ? ema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// HMA, Hull

_hma(src, length) =>
	wma(2 * wma(src, length / 2) - wma(src, length), round(sqrt(length)))

smooth := maType == "HMA" ? _hma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// LSMA, Least Squares

smooth := maType == "LSMA" ? linreg(ratio, maPeriod, 0) : smooth

//------------------------------------------------------------------------------
// PWMA, Parabolic Weighted

_pwma(src, length) =>
	sum = 0.0
	weightSum = 0.0
	for i = 0 to length - 1
		weight = pow(length - i, 2)
		sum := sum + nz(src[i]) * weight
		weightSum := weightSum + weight
	sum / weightSum

smooth := maType == "PWMA" ? _pwma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// SMMA

smooth := maType == "SMMA" ? rma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// SMA

smooth := maType == "SMA" ? sma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// SWMA

_swma(src, length) =>
	sum = 0.0
	weightSum = 0.0
	for i = 0 to length - 1
		weight = sin(i * PI / (length + 1))
		sum := sum + nz(src[i]) * weight
		weightSum := weightSum + weight
	sum / weightSum

smooth := maType == "SWMA" ? _swma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// TEMA

_tema(src, length) =>
	ema1 = ema(src, length)
	ema2 = ema(ema1, length)
	ema3 = ema(ema2, length)
	3 * (ema1 - ema2) + ema3

smooth := maType == "TEMA" ? _tema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// TMA

_tma(src, length) =>
	sma(sma(src, ceil(length / 2)), floor(length / 2) + 1)

smooth := maType == "TMA" ? _tma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// VWMA

smooth := maType == "VWMA" ? vwma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// WMA

smooth := maType == "WMA" ? wma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// ZLEMA

_zlema(src, length) =>
	lag = length <= 2 ? 1 : floor((length - 1) / 2)
	ema(src + (src - nz(src[lag])), length)

smooth := maType == "ZLEMA" ? _zlema(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------
// JMA

_jma(src, length) =>
	alpha = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)
	out = 0.0
	e0 = 0.0
	e0 := (1 - alpha) * src + alpha * nz(e0[1])
	e1 = 0.0
	e1 := (1 - alpha) * (src - e0) + alpha * nz(e1[1])
	e2 = 0.0
	e2 := pow(1 - alpha, 2) * (e0 + e1 - nz(out[1])) + pow(alpha, 2) * nz(e2[1])
	out := e2 + nz(out[1])

smooth := maType == "JMA" ? _jma(ratio, maPeriod) : smooth

//------------------------------------------------------------------------------

tdf = tdfAbsRaw > 0 ? max(min(na(smooth) ? ratio : smooth, 1), -1) : 0.0

tdfColor = tdf > triggerUp ? #0ebb23 : tdf < triggerDown ? red : gray
plot(tdf, linewidth=2, color=tdfColor, transp=0)
hline(triggerUp, title="Trigger Up", linestyle=dotted)
hline(triggerDown, title="Trigger Down", linestyle=dotted)

plotshape(crossover(tdf, 0) and showZeroCrosses ? 0 : na, title="Zero Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0)
plotshape(crossunder(tdf, 0) and showZeroCrosses ? 0 : na, title="Zero Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0)

plotshape(crossover(tdf, triggerUp) and showLineCrosses ? triggerUp : na, title="Upper Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0)
plotshape(crossunder(tdf, triggerUp) and showLineCrosses ? triggerUp : na, title="Upper Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0)
plotshape(crossover(tdf, triggerDown) and showLineCrosses ? triggerDown : na, title="Lower Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0)
plotshape(crossunder(tdf, triggerDown) and showLineCrosses ? triggerDown : na, title="Lower Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0)

alertcondition(crossover(tdf, 0), title="Cross zero line up", message="TDF crossed zero line up!")
alertcondition(crossunder(tdf, 0), title="Cross zero line down", message="TDF crossed zero line down!")
alertcondition(crossover(tdf, triggerUp), title="Cross upper line up", message="TDF crossed upper line up!")
alertcondition(crossunder(tdf, triggerUp), title="Cross upper line down", message="TDF crossed upper line down!")
alertcondition(crossover(tdf, triggerDown), title="Cross lower line up", message="TDF crossed lower line up!")
alertcondition(crossunder(tdf, triggerDown), title="Cross lower line down", message="TDF crossed lower line down!")
TDFI Idea from Moey.jpg

I think it will be such a good addition to our site what do you think of it?
Looks interesting will see what I can do with it.

Re: Trend Direction Force Index Indicators MT4

Posted: Sat Dec 30, 2023 1:55 am
by moey_dw
mrtools wrote: Sat Dec 30, 2023 1:02 am Looks interesting will see what I can do with it.
Thanks Mrtools I think you will like this one

Re: Trend Direction Force Index Indicators MT4

Posted: Sun Dec 31, 2023 12:24 am
by dmnik
From version 3 I updated to V5 and fixed the errors that were in V4!

Re: Trend Direction Force Index Indicators MT4

Posted: Mon Jan 01, 2024 6:12 pm
by moey_dw
mrtools wrote: Sat Dec 30, 2023 1:02 am Looks interesting will see what I can do with it.
Bump Mrtools don't forget me 😄

Happy new year!!!

Re: Trend Direction Force Index Indicators MT4

Posted: Tue Jan 02, 2024 2:10 am
by mrtools
moey_dw wrote: Mon Jan 01, 2024 6:12 pm Bump Mrtools don't forget me 😄

Happy new year!!!
Happy new year to you too! Haven't forgot, have done a version but it doesn't seem right, so trying to figure out what is wrong with it. This is what I am getting now not in histogram version until I get it right.

Re: Trend Direction Force Index Indicators MT4

Posted: Tue Jan 02, 2024 2:30 am
by moey_dw
mrtools wrote: Tue Jan 02, 2024 2:10 am Happy new year to you too! Haven't forgot, have done a version but it doesn't seem right, so trying to figure out what is wrong with it. This is what I am getting now not in histogram version until I get it right.
THAT'S FANTASTIC

Looking forward to it whenever you are able to make it right.... so far have you notice it producing more signals than traditional TDFI? Possibly from using a short period JMA? I think? 🤔