OPEN-SOURCE SCRIPT
SMC Structures + Baseline pro

SMC Structures + Baseline pro Tuấn Anh
etLineStyle(lineOption) =>
lineOption == "┈" ? line.style_dotted : lineOption == "╌" ? line.style_dashed : line.style_solid
get_structure_highest_bar(lookback) =>
var int idx = 0
maxBar = bar_index > lookback ? ta.highestbars(high, lookback) : ta.highestbars(high, bar_index + 1)
for i = 0 to lookback - 1 by 1
if high[i+1] > high[i+2] and high <= high[i+1] and ((i+1) * -1) >= maxBar
idx := (i+1) * -1
idx := idx == 0 ? maxBar : idx
get_structure_lowest_bar(lookback) =>
var int idx = 0
minBar = bar_index > lookback ? ta.lowestbars(low, lookback) : ta.lowestbars(low, bar_index + 1)
for i = 0 to lookback - 1 by 1
if low[i+1] < low[i+2] and low >= low[i+1] and ((i+1) * -1) >= minBar
idx := (i+1) * -1
idx := idx == 0 ? minBar : idx
// ── JMA (Jurik Moving Average) ──────────────────────────────────
jma(src, length, power, phase) =>
phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5
beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)
alpha = math.pow(beta, power)
var float jmaVal = 0.0
var float e0 = 0.0
var float e1 = 0.0
var float e2 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 := (e0 + phaseRatio * e1 - nz(jmaVal[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
jmaVal := e2 + nz(jmaVal[1])
jmaVal
etLineStyle(lineOption) =>
lineOption == "┈" ? line.style_dotted : lineOption == "╌" ? line.style_dashed : line.style_solid
get_structure_highest_bar(lookback) =>
var int idx = 0
maxBar = bar_index > lookback ? ta.highestbars(high, lookback) : ta.highestbars(high, bar_index + 1)
for i = 0 to lookback - 1 by 1
if high[i+1] > high[i+2] and high <= high[i+1] and ((i+1) * -1) >= maxBar
idx := (i+1) * -1
idx := idx == 0 ? maxBar : idx
get_structure_lowest_bar(lookback) =>
var int idx = 0
minBar = bar_index > lookback ? ta.lowestbars(low, lookback) : ta.lowestbars(low, bar_index + 1)
for i = 0 to lookback - 1 by 1
if low[i+1] < low[i+2] and low >= low[i+1] and ((i+1) * -1) >= minBar
idx := (i+1) * -1
idx := idx == 0 ? minBar : idx
// ── JMA (Jurik Moving Average) ──────────────────────────────────
jma(src, length, power, phase) =>
phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5
beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)
alpha = math.pow(beta, power)
var float jmaVal = 0.0
var float e0 = 0.0
var float e1 = 0.0
var float e2 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 := (e0 + phaseRatio * e1 - nz(jmaVal[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
jmaVal := e2 + nz(jmaVal[1])
jmaVal
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.
