वेव इंजन प्रोटोकॉल

ATR volatility ACCUMULATION DCA
निर्माण तिथि: 2025-11-26 18:13:25 अंत में संशोधित करें: 2025-11-26 18:13:25
कॉपी: 0 क्लिक्स: 53
2
ध्यान केंद्रित करना
319
समर्थक

वेव इंजन प्रोटोकॉल वेव इंजन प्रोटोकॉल

यह सामान्य डीसीए नहीं है, यह मस्तिष्क के साथ एक तरंग इंजन है

रिटारगेटिंग डेटा ने पारंपरिक निवेश को सीधे धक्का दियाः 5% की गिरावट ने खरीदारी को ट्रिगर किया, 3.9% की वृद्धि ने बिक्री को ट्रिगर किया, लेकिन महत्वपूर्ण बात यह है किअस्थिरता इंजन एटीआर गतिशीलता के आधार पर मूल्यह्रास खरीदता है│बाजार में उतार-चढ़ाव जितना अधिक होता है, उतना ही अधिक खरीदारी की सीमा होती है, जो अधिकतम 40% तक समायोजित की जा सकती है │इसका मतलब है कि उच्च उतार-चढ़ाव के दौरान, रणनीति अधिक गिरावट का इंतजार करती है │

पारंपरिक डीसीए रणनीतियों के साथ समस्या यह है कि वे बेतुके हैं, और इस प्रोटोकॉल का मुख्य तर्क यह है किकेवल वास्तविक अवसरों के लिए फायरिंग करें❚ ATR ((14) के माध्यम से वर्तमान उतार-चढ़ाव की गणना करें, और फिर गतिशील रूप से longThreshPct पैरामीटर को समायोजित करें। उदाहरण के लिए, एक सामान्य 5% गिरावट खरीदें, लेकिन यदि वर्तमान उतार-चढ़ाव 20% तक पहुंचता है, तो वास्तविक खरीद मूल्यह्रास 6% तक बढ़ जाएगा।

8 पूर्व-निर्धारित विन्यास, प्रत्येक के लिए एक स्पष्ट आय की उम्मीद

बीटीसी चक्र संचय मोडः 5% गिरावट खरीद, 6% स्थिति, $ 500 की निश्चित राशि, लंबे समय तक धारकों के लिए उपयुक्त। बीटीसी शॉर्ट-टर्म आर्बिट्रेज मोडः 3.1% गिरावट खरीदी गई, 10% स्थिति, 6000 डॉलर की निश्चित राशि, 75% लाभ मार्जिन बेचा गया। ईटीएच उतार-चढ़ाव का कटौतीः 4.5% गिरावट खरीदी, 15% स्थिति, लागत रेखा से नीचे खरीदने की अनुमति, 30% मुनाफे की सीमा।

प्रत्येक कॉन्फ़िगरेशन को वापस परीक्षण और सत्यापित किया गया है, न कि दिमाग से तय किए गए पैरामीटर│SOL को 35% रिटर्न थ्रेशोल्ड और XRP को 10% रिटर्न थ्रेशोल्ड के रूप में कॉन्फ़िगर किया गया है, जो विभिन्न परिसंपत्तियों की अस्थिरता और तरलता में अंतर को दर्शाता है│

क्लस्टर सीलिंगः डीसीए रणनीति के सबसे बड़े नुकसान को हल करना

पारंपरिक डीसीए के साथ सबसे बड़ी समस्या यह है कि यह पता नहीं है कि खरीद कब बंद करनी है। इस प्रोटोकॉल को “क्लेस्टर सील” के साथ हल किया गया हैः या तो कीमतें औसत लागत से 3.9% बढ़ जाती हैं, या 10 लगातार चक्रों के लिए कोई योग्य खरीद अवसर नहीं है, वर्तमान संचयी क्लस्टर को सील करें।

सील किए जाने के बाद औसत लागत रेखा बिक्री के लिए एक संदर्भ रेखा बन जाती है❚ केवल कीमत सील लागत रेखा + मुनाफा थ्रेशोल्ड ((30%-75% के बीच) को तोड़ने के बाद, बिक्री को ट्रिगर किया जाएगा। ❚ यह अंतहीन खरीद और समय से पहले लाभ के अंत से बचा जाता है।

यदि लगातार 10 चक्रों में से कोई भी खरीद की शर्तों को ट्रिगर नहीं करता है, तो यह दर्शाता है कि बाजार स्थिर हो गया है, और आपको फसल के लिए तैयार रहना चाहिए, न कि जमा करना जारी रखना चाहिए।

फ्लाइंग व्हील प्रभावः लाभ के लिए सेवाएं खरीदना

फ्लाइंग व्हील मोड को सक्षम करने के बाद, प्रत्येक बिक्री से होने वाला मुनाफा नकदी के पूल में वापस आ जाता है, जिससे अगली बार खरीदे जाने वाले गोला-बारूद की मात्रा बढ़ जाती है।बैल बाजार में रणनीति को और अधिक गति दें

उदाहरण के लिएः \( 100,000 की शुरुआत, पहले दौर में 20% की वृद्धि हुई, बिक्री के बाद, नकद पूल \) 120,000 हो गया। अगली खरीद पर, 6% की स्थिति \( 7,200 है, न कि \) 6,000। समय के साथ, इस स्नोबॉल प्रभाव से लाभ में काफी वृद्धि होगी।

लेकिन इसके लिए एक कीमत भी चुकानी पड़ती है: बुल मार्केट के बाद के समय में, बहुत अधिक खरीद के कारण नकदी की कमी होती है, और एक बार की खरीद की सीमा को सख्ती से नियंत्रित करना पड़ता है।

जोखिम नियंत्रणः ट्रिपल बीमा तंत्र

पहलाः लागत रेखा से ऊपर खरीद नियंत्रण केवल औसत लागत से नीचे खरीद को सेट किया जा सकता है, ताकि आगे बढ़ने से बचा जा सके दोहरीः न्यूनतम राशि की सीमा। हर खरीद / बिक्री पर न्यूनतम डॉलर की राशि की आवश्यकता होती है, जिससे छोटे छोटे लेनदेन से बचा जा सकता है। तीसरा भारः अस्थिरता इंजन समायोजन. उच्च अस्थिरता के दौरान स्वचालित रूप से खरीदने की सीमा बढ़ाएं, कम अस्थिरता के दौरान सीमा को कम करें।

लेकिन यह रणनीति बाजार में उतार-चढ़ाव के दौरान काम करती है।यदि बाजार लंबे समय तक क्षैतिज हो जाता है, तो यह न तो एक बड़ी गिरावट को ट्रिगर कर सकता है और न ही लाभ सीमा तक पहुंच सकता है, तो फंड को लंबे समय तक लॉक कर दिया जाएगा।

युद्ध के सुझावः बाजार के लिए चुनाव महत्वपूर्ण है

यह समझौता स्पष्ट रूप से रुझान वाले बाजारों के लिए सबसे उपयुक्त है, विशेष रूप से क्रिप्टोकरेंसी की आवधिकता के लिए। बैल बाजार के अंत में जमा करना शुरू करना और बैल बाजार के मध्य में कटाई शुरू करना सबसे अच्छा है।

निम्नलिखित स्थितियों में इसका उपयोग न करेंः 1) उच्च आवृत्ति वाले शेयर बाजार 2) स्पष्ट प्रवृत्ति के बिना विदेशी मुद्रा बाजार 3) बहुत कम तरलता वाले छोटे सिक्के।

ऐतिहासिक समीक्षाओं से पता चलता है कि जोखिम के लिए समायोजित रिटर्न सरल निवेश से बेहतर है, लेकिन इसका मतलब यह नहीं है कि भविष्य में निश्चित रूप से लाभ होगाकिसी भी मात्रात्मक रणनीति में विफलता का जोखिम होता है और निरंतर निगरानी और समायोजन की आवश्यकता होती है।

रणनीति स्रोत कोड
//@version=6
// ============================================================================
//  ORACLE PROTOCOL — ARCH PUBLIC clone (Standalone) — CLEAN-PUB STYLE (derived)
//  Variant: v1.9v-standalone (publish-ready)  25/11/2025
//  Notes:
//   - Keeps your v1.9v canonical script intact (this is a separate modified copy).
//   - Single exit mode: ProfitGate + Candle (per-candle) — no selector.
//   - Live ACB plot toggle only (sealed ACB still operates internally but is not shown).
//   - No freeze-point markers plotted.
//   - Sizing: flywheel dynamic sizing remains the primary source but fixed-dollar entry
//     and min-$ overrides remain available (as in Arch public PDFs/screenshots).
//   - Volatility Engine (VE) applies ONLY to entries; exit-side VE removed.
//   - Manual equity top-up removed (flywheel auto-updates cash).
//   - VE ATR length and max-vol fields are fixed (not exposed in UI).
// ============================================================================

strategy("Oracle Protocol — Arch Public (Clone) • v1.9v-standalone (publish)",
     overlay=true,
     initial_capital=100000,
     commission_type=strategy.commission.percent,
     commission_value=0.1,
     pyramiding=9999,
     calc_on_every_tick=true,
     process_orders_on_close=true)


// ============================================================================
// 1) PRESETS (Arch PDFs)
// ============================================================================
grp_oracle  = "Oracle — Core"
oraclePreset = input.string(
     "BTC • Cycle Accumulation",
     "Recipe Preset",
     options = [
         "BTC • Cycle Accumulation",
         "BTC • Cycle Swing Arbitrage",
         "BTC • Short Target Accumulation",
         "BTC • Short Target Arbitrage",
         "ETH • Volatility Harvesting",
         "SOL • Volatility Harvesting",
         "XRP • Volatility Harvesting",
         "SUI • Volatility Harvesting"
     ],
     group = grp_oracle)

var float longThreshPct      = 0.0
var float exitThreshPct      = 0.0
var bool  onlySellAboveCost  = true
var bool  recipe_buyBelowACB = false
var float sellProfitGatePct  = 0.0
var float entryPct           = 0.0
var float exitPct            = 0.0
var float fixedEntryUsd      = 0.0
var float fixedExitUsd       = 0.0

if oraclePreset == "BTC • Cycle Accumulation"
    longThreshPct       := 5.0
    exitThreshPct       := 3.9
    onlySellAboveCost   := true
    recipe_buyBelowACB  := false
    sellProfitGatePct   := 50.0
    entryPct            := 6.0
    exitPct             := 1.0
    fixedEntryUsd       := 500
    fixedExitUsd        := 500
else if oraclePreset == "BTC • Cycle Swing Arbitrage"
    longThreshPct       := 5.9
    exitThreshPct       := 3.5
    onlySellAboveCost   := true
    recipe_buyBelowACB  := false
    sellProfitGatePct   := 49.0
    entryPct            := 10.0
    exitPct             := 50.0
    fixedEntryUsd       := 10000
    fixedExitUsd        := 15000
else if oraclePreset == "BTC • Short Target Accumulation"
    longThreshPct       := 3.1
    exitThreshPct       := 2.5
    onlySellAboveCost   := true
    recipe_buyBelowACB  := false
    sellProfitGatePct   := 30.0
    entryPct            := 10.0
    exitPct             := 10.0
    fixedEntryUsd       := 6000
    fixedExitUsd        := 5000
else if oraclePreset == "BTC • Short Target Arbitrage"
    longThreshPct       := 3.1
    exitThreshPct       := 2.5
    onlySellAboveCost   := true
    recipe_buyBelowACB  := true
    sellProfitGatePct   := 75.0
    entryPct            := 10.0
    exitPct             := 100.0
    fixedEntryUsd       := 10000
    fixedExitUsd        := 5000
else if oraclePreset == "ETH • Volatility Harvesting"
    longThreshPct       := 4.5
    exitThreshPct       := 5.0
    onlySellAboveCost   := true
    recipe_buyBelowACB  := true
    sellProfitGatePct   := 30.0
    entryPct            := 15.0
    exitPct             := 40.0
    fixedEntryUsd       := 6000
    fixedExitUsd        := 20000
else if oraclePreset == "SOL • Volatility Harvesting"
    longThreshPct       := 5.0
    exitThreshPct       := 5.0
    onlySellAboveCost   := true
    recipe_buyBelowACB  := false
    sellProfitGatePct   := 35.0
    entryPct            := 7.0
    exitPct             := 5.0
    fixedEntryUsd       := 5000
    fixedExitUsd        := 5000
else if oraclePreset == "XRP • Volatility Harvesting"
    longThreshPct       := 4.5
    exitThreshPct       := 10.0
    onlySellAboveCost   := true
    recipe_buyBelowACB  := false
    sellProfitGatePct   := 10.0
    entryPct            := 17.0
    exitPct             := 50.0
    fixedEntryUsd       := 8000
    fixedExitUsd        := 5000
else if oraclePreset == "SUI • Volatility Harvesting"
    longThreshPct       := 5.0
    exitThreshPct       := 5.0
    onlySellAboveCost   := true
    recipe_buyBelowACB  := false
    sellProfitGatePct   := 10.0
    entryPct            := 5.0
    exitPct             := 10.0
    fixedEntryUsd       := 5000
    fixedExitUsd        := 15000

// ============================================================================
// 2) EXTRAS & VOLATILITY SPLITS (CLEAN PUBLIC VARIANTS)
//    - Volatility engine inputs are fixed and not exposed in the UI
// ============================================================================
// UI group for extras (keeps flywheel toggle visible)
grp_extras = "Oracle — Extras"
useFlywheel          = input.bool(true,  "Reinvest Realized Profits (Flywheel)", group = grp_extras)
// Volatility engine: ENTRY only (VE params fixed, not shown)
useVolEngineEntry    = input.bool(true,  "Enable Volatility Engine (Entries only)", group = grp_extras)

// Fixed/hidden VE parameters (not exposed in UI per your request)
atrLen_fixed = 14
maxVolAdjPct_fixed = 40.0

// NOTE: manual_equity_topup removed for publish variant — flywheel handles auto top-up

buyBelowMode  = input.string(
     "Use Recipe Setting",
     "Buy Below ACB Mode",
     options = ["Use Recipe Setting", "Force Buy Below ACB", "Allow Buys Above ACB"],
     group = grp_extras)

// ============================================================================
// 3) QUIET BARS (cluster seal) — unchanged behavior, UI visible
// ============================================================================
grp_qb = "Oracle — Quiet Bars (Cluster Seal)"
useQuietBars   = input.bool(true, "Enable Quiet-Bars Seal", group=grp_qb)
quietBars      = input.int(10,   "Quiet Bars (no eligible buys)", minval=1, group=grp_qb)

// ============================================================================
// 4) SELL MODE — SINGLE ARCH EXIT (ProfitGate + Candle) ONLY
//    (no selector; fixed behavior to match Arch public)
// ============================================================================
grp_sell = "Oracle — Sell Behaviour"
// no sellMode selector in this publish variant — fixed logic below

// ============================================================================
// 5) DISPLAY & PLOTS (simplified)
//    - only Live ACB toggle remains visible.
//    - sealed ACB and freeze points are intentionally not plotted.
// ============================================================================
grp_display    = "Oracle — Display"
showLiveACB    = input.bool(true,  "Show Live ACB", group = grp_display)
acbColor       = input.color(color.new(color.yellow, 0), "ACB Line Color", group = grp_display)
showExitGuides = input.bool(false, "Show Exit Guide Lines",  group = grp_display)

// ============================================================================
// 6) 3C SIZING & MINIMUMS / OVERRIDES
//    - primary sizing source is flywheel (cash ledger).
//    - but fixed-entry USD and min-$ overrides remain (per Arch public).
// ============================================================================
grp_3c_sz = "Oracle — Sizing"
use3C  = input.bool(true, "Enable 3Commas JSON Alerts", group = grp_3c_sz)
botTag = input.string("ORACLE", "Bot Tag / Pair Hint",   group = grp_3c_sz)

// Keep min$/fixed entry & exit overrides visible (Arch style)
useMinEntry     = input.bool(true,  "Use Min $ on Entry",                  group = grp_oracle)
useMinExit      = input.bool(true,  "Use Min $ on Exit",                   group = grp_oracle)
manualMinEntry  = input.float(0.0,  "Manual Min $ Entry (0 = use recipe)", group = grp_oracle, step = 10)
manualMinExit   = input.float(0.0,  "Manual Min $ Exit (0 = use recipe)",  group = grp_oracle, step = 10)

grp_override      = "Oracle — Amount Override"
entryUsd_override = input.float(0.0, "Entry USD Override (0 = none)", group = grp_override, step = 10)
exitUsd_override  = input.float(0.0, "Exit USD Override (0 = none)",  group = grp_override, step = 10)

// ============================================================================
// 7) VOLATILITY ENGINE VALUES (ENTRY only)
//    - VE uses fixed internal params (atrLen_fixed, maxVolAdjPct_fixed).
//    - VE not applied to exits in this publish variant.
// ============================================================================
atrVal        = ta.atr(atrLen_fixed)
volPct        = atrVal / close * 100.0
volAdj        = math.min(volPct, maxVolAdjPct_fixed)
longThreshEff = longThreshPct * (useVolEngineEntry ? (1 + volAdj/100.0) : 1)
// exit threshold is NOT adjusted by VE in this variant:
exitThreshEff = exitThreshPct

// ============================================================================
// 8) POSITION STATE & HELPERS
// ============================================================================
var float q        = 0.0          // live coin quantity
var float cost     = 0.0          // live position cost ($)
var float live_acb = 0.0          // live average cost (cost / q)
var float realized = 0.0

// Flywheel cash ledger (realised cash available for reinvest) — auto only
var float cash = na
if na(cash)
    cash := strategy.initial_capital

// Cluster / gating state (sealed base) — sealed_acb still used internally but not shown
var bool  clusterOpen      = false
var float sealed_acb       = na     // frozen when a cluster seals (sealed accumulation base)
var int   lastEntryBar     = na
var int   lastEligibleBuyBar = na   // for quiet-bars seal
var int   sell_steps_done  = 0      // number of incremental exits already taken since gate armed
var float last_sell_ref    = na     // last sell price used for pullback re-arm (not used here)
var bool  mode_single_sold = false  // lock for Single per Rally (internal use)

// Helpers (array returns)
f_add_fill(_qty, _px, _q, _cost) =>
    // returns newQty, newCost, newACB
    _newCost = _cost + _qty * _px
    _newQty  = _q + _qty
    _newACB  = _newQty > 0 ? _newCost / _newQty : 0.0
    array.from(_newQty, _newCost, _newACB)

f_reduce_fill(_qty, _px, _q, _cost) =>
    // returns newQty, newCost, newACB, sellVal, costReduced, proportion
    _sellVal     = _qty * _px
    _prop        = _q > 0 ? _qty / _q : 0.0
    _costReduced = _cost * _prop
    _newCost     = _cost - _costReduced
    _newQty      = _q - _qty
    _newACB      = _newQty > 0 ? _newCost / _newQty : 0.0
    array.from(_newQty, _newCost, _newACB, _sellVal, _costReduced, _prop)

// ============================================================================
// 9) BUY SIGNALS & BUY-BELOW MODE
// ============================================================================
dropFromPrev = close[1] != 0 ? (close - close[1]) / close[1] * 100.0 : 0.0
wantBuy      = dropFromPrev <= -longThreshEff

needBuyBelow = recipe_buyBelowACB
if buyBelowMode == "Force Buy Below ACB"
    needBuyBelow := true
else if buyBelowMode == "Allow Buys Above ACB"
    needBuyBelow := false
canBuyBelow = not needBuyBelow or (needBuyBelow and (live_acb == 0 or close < live_acb))

// Track “eligible” buys (quiet-bars gate references opportunity, not just fills)
if wantBuy and canBuyBelow
    lastEligibleBuyBar := bar_index

// ============================================================================
// 10) SIZING (flywheel-driven; keep fixed/min-dollar options for entry & exit)
// ============================================================================
baseAcct   = cash  // flywheel only in this variant
// entry as percentage of baseAcct (dynamic) with fixed/min-dollar fallback (Arch-style)
entryUsd   = baseAcct * (entryPct / 100.0)

// Entry min floor (keep manual/fixed options per Arch)
if useMinEntry
    entryFloor = manualMinEntry > 0 ? manualMinEntry : fixedEntryUsd
    entryUsd   := math.max(entryUsd, entryFloor)

// override priority
entryUsd := entryUsd_override > 0 ? entryUsd_override : entryUsd

// entry qty
eQty = close > 0 ? entryUsd / close : 0.0

// Exit sizing: percentage of HOLDINGS (Arch) with min-$ fallback (unchanged)
exitQty_pct = q * (exitPct / 100.0)
exitFloorQty = close > 0 ? ( (manualMinExit > 0 ? manualMinExit : fixedExitUsd) / close ) : 0.0
xQty_base = math.max(exitQty_pct, exitFloorQty)
xQty = math.min(xQty_base, q)
xQty := exitUsd_override > 0 and close > 0 ? math.min(exitUsd_override / close, q) : xQty

// ============================================================================
// 11) ENTRY — opens/extends accumulation cluster; resets SELL steps
//       Cash gate: only execute buy if cash >= entryUsd and on confirmed bar close
// ============================================================================
newEntry = false
entryCost = eQty * close
hasCash = entryCost > 0 and cash >= entryCost

if barstate.isconfirmed and wantBuy and canBuyBelow and eQty > 0 and hasCash
    strategy.entry("ORACLE-LONG", strategy.long, qty=eQty, comment="ORACLE-BUY")
    _fill = f_add_fill(eQty, close, q, cost)
    q     := array.get(_fill, 0)
    cost  := array.get(_fill, 1)
    live_acb := array.get(_fill, 2)
    cash  -= entryCost
    lastEntryBar       := bar_index
    lastEligibleBuyBar := bar_index
    if not clusterOpen
        clusterOpen := true
        sealed_acb := na
        sell_steps_done := 0
        mode_single_sold := false
        last_sell_ref := na
    // set sealed_acb initial for cluster if na
    if na(sealed_acb)
        sealed_acb := live_acb
    newEntry := true

// ============================================================================
// 12) CLUSTER SEAL — Exit-Threshold OR Quiet-Bars
//    - On sealing, we freeze sealed_acb internally (not plotted).
// ============================================================================
riseFromLiveACB   = live_acb  > 0 ? (close - live_acb ) / live_acb  * 100.0 : 0.0
sealByThresh  = riseFromLiveACB >= exitThreshEff
barsSinceElig = na(lastEligibleBuyBar) ? 10000 : (bar_index - lastEligibleBuyBar)
sealByQuiet   = useQuietBars and (barsSinceElig >= quietBars)

sealed_changed = false
if clusterOpen and (sealByThresh or sealByQuiet)
    clusterOpen := false
    // freeze sealed base as the last live_acb at seal time (preserve cycle anchor)
    sealed_acb := live_acb
    sell_steps_done := 0
    mode_single_sold := false
    last_sell_ref := na
    sealed_changed := true

// ============================================================================
// 13) SELL LOGIC — SINGLE ARCH EXIT: ProfitGate + Candle (Per-Candle)
//    - Profit gate base: use sealed refBase if present, otherwise live_acb (no toggle).
//    - VE not applied to exits in this variant.
// ============================================================================
refBase      = na(sealed_acb) ? live_acb : sealed_acb
riseFromRef  = refBase > 0 ? (close - refBase) / refBase * 100.0 : 0.0
sellAboveOK  = not onlySellAboveCost or close > live_acb

profitRefBase = refBase  // sealed if available, else live_acb (no UI toggle in this variant)

// Basic profit gate price/boolean (uses profitRefBase)
profitGateLevelPrice = profitRefBase * (1 + sellProfitGatePct / 100.0)
profitGateCrossed = profitRefBase > 0 ? (close >= profitGateLevelPrice) : false

// Candle-based rise (percent move relative to previous close)
riseFromPrev = close[1] != 0 ? (close - close[1]) / close[1] * 100.0 : 0.0
candleRiseOK = riseFromPrev >= exitThreshEff

// Final allow-sell boolean for this publish variant (ProfitGate + Candle)
var bool allowSellThisBar = false
allowSellThisBar := false
allowSellThisBar := profitGateCrossed and candleRiseOK and xQty > 0 and q > 0 and sellAboveOK and barstate.isconfirmed 

// Perform sell if allowed
actualExitQty = 0.0
if allowSellThisBar
    actualExitQty := xQty
    if actualExitQty > 0
        strategy.close("ORACLE-LONG", qty = actualExitQty, comment = "ORACLE-SELL")
        _r = f_reduce_fill(actualExitQty, close, q, cost)
        q       := array.get(_r, 0)
        cost    := array.get(_r, 1)
        live_acb := array.get(_r, 2)
        sellVal =  array.get(_r, 3)
        cRed    =  array.get(_r, 4)
        tradePnL = sellVal - cRed
        realized += tradePnL
        cash     += sellVal
        sell_steps_done += 1
        last_sell_ref := close
        mode_single_sold := true
        if q <= 0
            // fully sold - reset sealed base and steps (internal)
            sealed_acb := na
            sell_steps_done := 0
            mode_single_sold := false
            last_sell_ref := na

// Re-arm logic (simplified): allow new sells only after retrace below refBase by exitThreshEff or if fully sold
if barstate.isconfirmed 
    if mode_single_sold
        retrace_condition = not na(refBase) ? (close < refBase * (1 - exitThreshEff/100.0)) : false
        if retrace_condition or q == 0
            mode_single_sold := false
            sell_steps_done := 0
            last_sell_ref := na

// ============================================================================
// 14) BALANCES & 3C JSON (flywheel-based sizing)
// ============================================================================
cash_on_hand = math.max(cash, 0)
coin_value   = q * close
total_equity = cash_on_hand + coin_value

base_for_3c = cash_on_hand  // flywheel only in this publish variant

entryUsd_3c = base_for_3c * (entryPct / 100.0)
if useMinEntry
    entryUsd_3c := math.max(entryUsd_3c, (manualMinEntry > 0 ? manualMinEntry : fixedEntryUsd))
entryUsd_3c := entryUsd_override > 0 ? entryUsd_override : entryUsd_3c



// ============================================================================
// 15) PLOTS (Data Window + Live ACB only + optional guides)
//    - Sealed ACB and freeze markers intentionally NOT plotted in this variant.
// ============================================================================
plot(strategy.initial_capital, title="Initial Capital",  color=color.white)
plot(q,            title="Oracle Coin Qty",    precision = 6)
plot(cost,         title="Oracle Position Cost")
plot(coin_value,   title="Oracle Coin Value")
plot(cash_on_hand, title="Oracle Cash On Hand")
plot(total_equity, title="Oracle Total Equity")

plot(live_acb > 0 and showLiveACB ? live_acb : na, title="Live ACB", color=color.new(color.orange,0), linewidth=2, style=plot.style_line)

// Exit guide lines reference refBase but are optional (kept for debugging/visual confirmation)
guide_exit_line = showExitGuides and not na(refBase) ? refBase * (1 + exitThreshEff/100.0) : na
guide_gate_line = showExitGuides and not na(refBase) ? refBase * (1 + sellProfitGatePct/100.0) : na
plot(guide_exit_line, title="Exit Threshold Line", display=showExitGuides ? display.all : display.none, linewidth=1, style=plot.style_linebr)
plot(guide_gate_line, title="Profit Gate Line (ref base)", display=showExitGuides ? display.all : display.none, linewidth=1, style=plot.style_linebr)

// Also plot the profit gate price computed from profitRefBase (if guides enabled)
plot(not na(profitRefBase) and showExitGuides ? profitRefBase * (1 + sellProfitGatePct/100.0) : na, title="Profit Gate (ref base)", display=showExitGuides ? display.all : display.none, linewidth=1, style=plot.style_line)