Page 1 of 1

Convert MTF

Posted: Sun Mar 05, 2023 8:25 am
by romeo
Hi All

Any one please help to convert the following to MTF


//@version=3
study("FLC LH MTF","FLC LH MTF",overlay=true)

ma_len=input(14,"EMA parameter", integer)
length00 = input(14)
fmultiplier = 0.01
// ||---
trend = ema(ohlc4, length00)
hhi1 = ohlc4 < trend ? valuewhen(cross(ohlc4,trend), lowest(low, length00), 0) : lowest(low, length00)
llo1 = ohlc4 > trend ? valuewhen(cross(ohlc4,trend), highest(high, length00), 0) : highest(high, length00)
//hhi1 = lowest(low, length00)
//llo1 = highest(high, length00)
hhi2 = ohlc4 < trend ? valuewhen(cross(ohlc4,trend), highest(low, length00), 0) : highest(low, length00)
llo2 = ohlc4 > trend ? valuewhen(cross(ohlc4,trend), lowest(high, length00), 0) : lowest(high, length00)
//hhi2 = highest(low, length00)
//llo2 = lowest(high, length00)
// ||---
fraction1 = (hhi1 - llo1) * fmultiplier
//midline1 = llo1 + fraction * 4
//midline1 = (hhi1 + llo1)/2
midline1 = barssince(high >= hhi1) >= barssince(low <= llo1) ? llo1 : hhi1
fraction2 = (hhi2 - llo2) * fmultiplier
//midline2 = llo2 + fraction * 4
//midline2 = (hhi2 + llo2)/2
midline2 = barssince(high >= hhi2) >= barssince(low <= llo2) ? llo2 : hhi2

//plot(midline1, color=gray, linewidth=3)
//plot(midline2, color=gray, linewidth=3)

fib0 = midline1 == hhi1 ? hhi1 : llo1
fib1 = midline1 == hhi1 ? hhi1 - fraction1 * 23.6 : llo1 + fraction1 * 23.6
fib2 = midline1 == hhi1 ? hhi1 - fraction1 * 38.2 : llo1 + fraction1 * 38.2
fib3 = midline1 == hhi1 ? hhi1 - fraction1 * 50.0 : llo1 + fraction1 * 50.0
fib4 = midline1 == hhi1 ? hhi1 - fraction1 * 61.8 : llo1 + fraction1 * 61.8
fib5 = midline1 == hhi1 ? hhi1 - fraction1 * 76.4 : llo1 + fraction1 * 76.4
fib6 = midline1 == hhi1 ? hhi1 - fraction1 * 100.0 : llo1 + fraction1 * 100.0

fib10 = midline2 == hhi2 ? hhi2 : llo2
fib11 = midline2 == hhi2 ? hhi2 - fraction2 * 23.6 : llo2 + fraction2 * 23.6
fib12 = midline2 == hhi2 ? hhi2 - fraction2 * 38.2 : llo2 + fraction2 * 38.2
fib13 = midline2 == hhi2 ? hhi2 - fraction2 * 50.0 : llo2 + fraction2 * 50.0
fib14 = midline2 == hhi2 ? hhi2 - fraction2 * 61.8 : llo2 + fraction2 * 61.8
fib15 = midline2 == hhi2 ? hhi2 - fraction2 * 76.4 : llo2 + fraction2 * 76.4
fib16 = midline2 == hhi2 ? hhi2 - fraction2 * 100.0 : llo2 + fraction2 * 100.0

out0= security(tickerid, "D",(fib0))

lnwd=3

plot(out0,"D",#363A45,transp=0,linewidth=lnwd)


tHANKS IN ADVANCE