From e1067f211a15d0668af42fc14579676202219b92 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 18 Oct 2025 20:59:41 +0200 Subject: [PATCH] v5: add Calculation source toggle (Chart vs Heikin Ashi) with ATR computed from selected OHLC; strategy uses HA signals but fills on chart bars --- Bullmania_Money_Line_Strategy_v5.pine | 24 +++++++++++++++++------- Bullmania_Money_Line_v5.pine | 26 +++++++++++++++++++------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Bullmania_Money_Line_Strategy_v5.pine b/Bullmania_Money_Line_Strategy_v5.pine index 7bfd7ec..842f481 100644 --- a/Bullmania_Money_Line_Strategy_v5.pine +++ b/Bullmania_Money_Line_Strategy_v5.pine @@ -13,6 +13,8 @@ strategy( calc_on_every_tick=false ) +// Calculation source (Chart vs Heikin Ashi) +srcMode = input.string("Chart", "Calculation source", options=["Chart","Heikin Ashi"], tooltip="Use regular chart candles or Heikin Ashi for signal calculation. Fills occur on chart bars.") // Parameter Mode paramMode = input.string("Profiles by timeframe", "Parameter Mode", options=["Single", "Profiles by timeframe"], tooltip="Choose whether to use one global set of parameters or timeframe-specific profiles.") @@ -81,9 +83,17 @@ atrPeriod = profileBucket == "Single" ? atrPeriodSingle : profileBucket == "Minu multiplier = profileBucket == "Single" ? multiplierSingle : profileBucket == "Minutes" ? mult_m : profileBucket == "Hours" ? mult_h : profileBucket == "Daily" ? mult_d : mult_w activeProfile := profileBucket -// Core Money Line logic (unchanged from v1) -atr = ta.atr(atrPeriod) -src = (high + low) / 2 +// Core Money Line logic (with selectable source) +haTicker = ticker.heikinashi(syminfo.tickerid) +[haO, haH, haL, haC] = request.security(haTicker, timeframe.period, [open, high, low, close], lookahead=barmerge.lookahead_off) +calcH = srcMode == "Heikin Ashi" ? haH : high +calcL = srcMode == "Heikin Ashi" ? haL : low +calcC = srcMode == "Heikin Ashi" ? haC : close + +// ATR on selected source +tr = math.max(calcH - calcL, math.max(math.abs(calcH - calcC[1]), math.abs(calcL - calcC[1]))) +atr = ta.rma(tr, atrPeriod) +src = (calcH + calcL) / 2 up = src - (multiplier * atr) dn = src + (multiplier * atr) @@ -94,8 +104,8 @@ var float dn1 = na up1 := nz(up1[1], up) dn1 := nz(dn1[1], dn) -up1 := close[1] > up1 ? math.max(up, up1) : up -dn1 := close[1] < dn1 ? math.min(dn, dn1) : dn +up1 := calcC[1] > up1 ? math.max(up, up1) : up +dn1 := calcC[1] < dn1 ? math.min(dn, dn1) : dn var int trend = 1 var float tsl = na @@ -104,10 +114,10 @@ tsl := nz(tsl[1], up1) if trend == 1 tsl := math.max(up1, tsl) - trend := close < tsl ? -1 : 1 + trend := calcC < tsl ? -1 : 1 else tsl := math.min(dn1, tsl) - trend := close > tsl ? 1 : -1 + trend := calcC > tsl ? 1 : -1 supertrend = tsl diff --git a/Bullmania_Money_Line_v5.pine b/Bullmania_Money_Line_v5.pine index b1c20c1..95780cb 100644 --- a/Bullmania_Money_Line_v5.pine +++ b/Bullmania_Money_Line_v5.pine @@ -1,6 +1,9 @@ //@version=5 indicator("Bullmania Money Line v5", overlay=true) +// Calculation source (Chart vs Heikin Ashi) +srcMode = input.string("Chart", "Calculation source", options=["Chart","Heikin Ashi"], tooltip="Use regular chart candles or Heikin Ashi for the line calculation.") + // Parameter Mode paramMode = input.string("Profiles by timeframe", "Parameter Mode", options=["Single", "Profiles by timeframe"], tooltip="Choose whether to use one global set of parameters or timeframe-specific profiles.") @@ -63,9 +66,18 @@ atrPeriod = profileBucket == "Single" ? atrPeriodSingle : profileBucket == "Minu multiplier = profileBucket == "Single" ? multiplierSingle : profileBucket == "Minutes" ? mult_m : profileBucket == "Hours" ? mult_h : profileBucket == "Daily" ? mult_d : mult_w activeProfile := profileBucket -// Core Money Line logic (unchanged from v1) -atr = ta.atr(atrPeriod) -src = (high + low) / 2 +// Core Money Line logic (with selectable source) +// Build selected source OHLC +haTicker = ticker.heikinashi(syminfo.tickerid) +[haO, haH, haL, haC] = request.security(haTicker, timeframe.period, [open, high, low, close], lookahead=barmerge.lookahead_off) +calcH = srcMode == "Heikin Ashi" ? haH : high +calcL = srcMode == "Heikin Ashi" ? haL : low +calcC = srcMode == "Heikin Ashi" ? haC : close + +// ATR on selected source +tr = math.max(calcH - calcL, math.max(math.abs(calcH - calcC[1]), math.abs(calcL - calcC[1]))) +atr = ta.rma(tr, atrPeriod) +src = (calcH + calcL) / 2 up = src - (multiplier * atr) dn = src + (multiplier * atr) @@ -76,8 +88,8 @@ var float dn1 = na up1 := nz(up1[1], up) dn1 := nz(dn1[1], dn) -up1 := close[1] > up1 ? math.max(up, up1) : up -dn1 := close[1] < dn1 ? math.min(dn, dn1) : dn +up1 := calcC[1] > up1 ? math.max(up, up1) : up +dn1 := calcC[1] < dn1 ? math.min(dn, dn1) : dn var int trend = 1 var float tsl = na @@ -86,10 +98,10 @@ tsl := nz(tsl[1], up1) if trend == 1 tsl := math.max(up1, tsl) - trend := close < tsl ? -1 : 1 + trend := calcC < tsl ? -1 : 1 else tsl := math.min(dn1, tsl) - trend := close > tsl ? 1 : -1 + trend := calcC > tsl ? 1 : -1 supertrend = tsl