This commit is contained in:
wvr committed 2026-11-22 11:07:56 -06:00
1 parent 3dc58091b7
commit 868751f464
1 file changed
+226 -2
+226 -2
View File
@@ -33,7 +33,7 @@
// Works on any chart timeframe (1 min, 5 min, 1 hour...): every signal is computed from 1-minute data of each contract. // Works on any chart timeframe (1 min, 5 min, 1 hour...): every signal is computed from 1-minute data of each contract.
// Continuous "1!" symbols are fine (roll days change the NQ side about once a year and a few gold signals a year). // Continuous "1!" symbols are fine (roll days change the NQ side about once a year and a few gold signals a year).
// Exact months (e.g. NQZ2026) avoid even that, if you prefer. // Exact months (e.g. NQZ2026) avoid even that, if you prefer.
// Skip US market holidays and early-close days. The Bracket Tracker remains the source for each account's own stop/target $. // Skip US market holidays and early-close days. Per-account stop/target $: the account table (bottom right; fill it in Settings).
// Signals lock the moment the decision candle has closed (gold: 8:19 candle -> shown from 8:20; NQ: the 8:30 / 9:30 candle -> from 8:31 / 9:31, else the 8:32 / 9:32 candle -> from 8:33 / 9:33), // Signals lock the moment the decision candle has closed (gold: 8:19 candle -> shown from 8:20; NQ: the 8:30 / 9:30 candle -> from 8:31 / 9:31, else the 8:32 / 9:32 candle -> from 8:33 / 9:33),
// using that candle's final close, so they never flicker. Until then the side shows "waiting". // using that candle's final close, so they never flicker. Until then the side shows "waiting".
// Set alerts to "Once Per Bar" so they fire the moment the side is known (with "Once Per Bar Close" a 5-minute chart alerts up to 5 minutes late). // Set alerts to "Once Per Bar" so they fire the moment the side is known (with "Once Per Bar Close" a 5-minute chart alerts up to 5 minutes late).
@@ -396,10 +396,234 @@ if barstate.islast
table.cell(t, 9, 4, pts(nqTp), text_color = color.new(color.lime, 40)) table.cell(t, 9, 4, pts(nqTp), text_color = color.new(color.lime, 40))
endTxt = not endOn ? "" : needUsd <= endThr ? "ENDGAME: needs " + usd(needUsd) + " -> 1:1 stop (" + usd(needUsd) + "). Set back to 0 for other accounts. " : "ENDGAME: needs " + usd(needUsd) + " -> target " + usd(needUsd) + ", stop all the room. Set back to 0 for other accounts. " endTxt = not endOn ? "" : needUsd <= endThr ? "ENDGAME: needs " + usd(needUsd) + " -> 1:1 stop (" + usd(needUsd) + "). Set back to 0 for other accounts. " : "ENDGAME: needs " + usd(needUsd) + " -> target " + usd(needUsd) + ", stop all the room. Set back to 0 for other accounts. "
note = endTxt + "Stop = exactly the room (no cost allowance; a stop-out ends the account either way). Target includes commission. Type as shown. Yellow = micros. Per-account sizes: tracker. Skip holidays and early closes." note = endTxt + "Stop = exactly the room (no cost allowance; a stop-out ends the account either way). Target includes commission. Type as shown. Yellow = micros. Per-account sizes: account table (bottom right). Skip holidays and early closes."
table.cell(t, 0, 5, note, text_color = color.new(color.white, 30), text_size = size.small) table.cell(t, 0, 5, note, text_color = color.new(color.white, 30), text_size = size.small)
table.merge_cells(t, 0, 5, 9, 5) table.merge_cells(t, 0, 5, 9, 5)
// ---------- account table (per-account sizing for manual trading) ----------
grpA = "Account table"
showAcct = input.bool(true, "Show account table", group = grpA, display = display.none)
acctEnd = input.bool(false, "Evaluations: 1:1 stop when still needed <= endgame threshold", group = grpA, tooltip = "Off by default (tested neutral). Uses the endgame threshold above.", display = display.none)
a1Name = input.string("", "Name", group = "Account 1", inline = "1a", display = display.none)
a1Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 1", inline = "1a", display = display.none)
a1Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 1", inline = "1a", display = display.none)
a1Bal = input.float(0, "Balance", step = 1, group = "Account 1", inline = "1b", display = display.none)
a1Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 1", inline = "1b", display = display.none)
a1Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 1", inline = "1b", display = display.none)
a1C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 1", inline = "1c", display = display.none)
a1Best = input.float(0, "Best day this cycle", step = 1, group = "Account 1", inline = "1c", display = display.none)
a1Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 1", inline = "1c", display = display.none)
a2Name = input.string("", "Name", group = "Account 2", inline = "2a", display = display.none)
a2Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 2", inline = "2a", display = display.none)
a2Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 2", inline = "2a", display = display.none)
a2Bal = input.float(0, "Balance", step = 1, group = "Account 2", inline = "2b", display = display.none)
a2Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 2", inline = "2b", display = display.none)
a2Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 2", inline = "2b", display = display.none)
a2C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 2", inline = "2c", display = display.none)
a2Best = input.float(0, "Best day this cycle", step = 1, group = "Account 2", inline = "2c", display = display.none)
a2Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 2", inline = "2c", display = display.none)
a3Name = input.string("", "Name", group = "Account 3", inline = "3a", display = display.none)
a3Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 3", inline = "3a", display = display.none)
a3Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 3", inline = "3a", display = display.none)
a3Bal = input.float(0, "Balance", step = 1, group = "Account 3", inline = "3b", display = display.none)
a3Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 3", inline = "3b", display = display.none)
a3Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 3", inline = "3b", display = display.none)
a3C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 3", inline = "3c", display = display.none)
a3Best = input.float(0, "Best day this cycle", step = 1, group = "Account 3", inline = "3c", display = display.none)
a3Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 3", inline = "3c", display = display.none)
a4Name = input.string("", "Name", group = "Account 4", inline = "4a", display = display.none)
a4Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 4", inline = "4a", display = display.none)
a4Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 4", inline = "4a", display = display.none)
a4Bal = input.float(0, "Balance", step = 1, group = "Account 4", inline = "4b", display = display.none)
a4Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 4", inline = "4b", display = display.none)
a4Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 4", inline = "4b", display = display.none)
a4C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 4", inline = "4c", display = display.none)
a4Best = input.float(0, "Best day this cycle", step = 1, group = "Account 4", inline = "4c", display = display.none)
a4Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 4", inline = "4c", display = display.none)
a5Name = input.string("", "Name", group = "Account 5", inline = "5a", display = display.none)
a5Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 5", inline = "5a", display = display.none)
a5Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 5", inline = "5a", display = display.none)
a5Bal = input.float(0, "Balance", step = 1, group = "Account 5", inline = "5b", display = display.none)
a5Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 5", inline = "5b", display = display.none)
a5Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 5", inline = "5b", display = display.none)
a5C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 5", inline = "5c", display = display.none)
a5Best = input.float(0, "Best day this cycle", step = 1, group = "Account 5", inline = "5c", display = display.none)
a5Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 5", inline = "5c", display = display.none)
a6Name = input.string("", "Name", group = "Account 6", inline = "6a", display = display.none)
a6Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 6", inline = "6a", display = display.none)
a6Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 6", inline = "6a", display = display.none)
a6Bal = input.float(0, "Balance", step = 1, group = "Account 6", inline = "6b", display = display.none)
a6Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 6", inline = "6b", display = display.none)
a6Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 6", inline = "6b", display = display.none)
a6C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 6", inline = "6c", display = display.none)
a6Best = input.float(0, "Best day this cycle", step = 1, group = "Account 6", inline = "6c", display = display.none)
a6Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 6", inline = "6c", display = display.none)
a7Name = input.string("", "Name", group = "Account 7", inline = "7a", display = display.none)
a7Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 7", inline = "7a", display = display.none)
a7Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 7", inline = "7a", display = display.none)
a7Bal = input.float(0, "Balance", step = 1, group = "Account 7", inline = "7b", display = display.none)
a7Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 7", inline = "7b", display = display.none)
a7Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 7", inline = "7b", display = display.none)
a7C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 7", inline = "7c", display = display.none)
a7Best = input.float(0, "Best day this cycle", step = 1, group = "Account 7", inline = "7c", display = display.none)
a7Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 7", inline = "7c", display = display.none)
a8Name = input.string("", "Name", group = "Account 8", inline = "8a", display = display.none)
a8Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 8", inline = "8a", display = display.none)
a8Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 8", inline = "8a", display = display.none)
a8Bal = input.float(0, "Balance", step = 1, group = "Account 8", inline = "8b", display = display.none)
a8Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 8", inline = "8b", display = display.none)
a8Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 8", inline = "8b", display = display.none)
a8C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 8", inline = "8c", display = display.none)
a8Best = input.float(0, "Best day this cycle", step = 1, group = "Account 8", inline = "8c", display = display.none)
a8Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 8", inline = "8c", display = display.none)
a9Name = input.string("", "Name", group = "Account 9", inline = "9a", display = display.none)
a9Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 9", inline = "9a", display = display.none)
a9Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 9", inline = "9a", display = display.none)
a9Bal = input.float(0, "Balance", step = 1, group = "Account 9", inline = "9b", display = display.none)
a9Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 9", inline = "9b", display = display.none)
a9Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 9", inline = "9b", display = display.none)
a9C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 9", inline = "9c", display = display.none)
a9Best = input.float(0, "Best day this cycle", step = 1, group = "Account 9", inline = "9c", display = display.none)
a9Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 9", inline = "9c", display = display.none)
a10Name = input.string("", "Name", group = "Account 10", inline = "10a", display = display.none)
a10Mkt = input.string("Off", "Market", options = ["Off", "Gold", "Crude", "NQ", "Nat gas"], group = "Account 10", inline = "10a", display = display.none)
a10Stg = input.string("Eval", "Stage", options = ["Eval", "Funded"], group = "Account 10", inline = "10a", display = display.none)
a10Bal = input.float(0, "Balance", step = 1, group = "Account 10", inline = "10b", display = display.none)
a10Flr = input.float(0, "Drawdown limit", step = 1, group = "Account 10", inline = "10b", display = display.none)
a10Tgt = input.float(53000, "Target (eval)", step = 1, group = "Account 10", inline = "10b", display = display.none)
a10C0 = input.float(50000, "Funded: cycle start balance", step = 1, group = "Account 10", inline = "10c", display = display.none)
a10Best = input.float(0, "Best day this cycle", step = 1, group = "Account 10", inline = "10c", display = display.none)
a10Pay = input.int(1, "Next payout #", minval = 1, maxval = 5, group = "Account 10", inline = "10c", display = display.none)
aName = array.from(a1Name, a2Name, a3Name, a4Name, a5Name, a6Name, a7Name, a8Name, a9Name, a10Name)
aMkt = array.from(a1Mkt, a2Mkt, a3Mkt, a4Mkt, a5Mkt, a6Mkt, a7Mkt, a8Mkt, a9Mkt, a10Mkt)
aStg = array.from(a1Stg, a2Stg, a3Stg, a4Stg, a5Stg, a6Stg, a7Stg, a8Stg, a9Stg, a10Stg)
aBal = array.from(a1Bal, a2Bal, a3Bal, a4Bal, a5Bal, a6Bal, a7Bal, a8Bal, a9Bal, a10Bal)
aFlr = array.from(a1Flr, a2Flr, a3Flr, a4Flr, a5Flr, a6Flr, a7Flr, a8Flr, a9Flr, a10Flr)
aTgt = array.from(a1Tgt, a2Tgt, a3Tgt, a4Tgt, a5Tgt, a6Tgt, a7Tgt, a8Tgt, a9Tgt, a10Tgt)
aC0 = array.from(a1C0, a2C0, a3C0, a4C0, a5C0, a6C0, a7C0, a8C0, a9C0, a10C0)
aBest = array.from(a1Best, a2Best, a3Best, a4Best, a5Best, a6Best, a7Best, a8Best, a9Best, a10Best)
aPay = array.from(a1Pay, a2Pay, a3Pay, a4Pay, a5Pay, a6Pay, a7Pay, a8Pay, a9Pay, a10Pay)
// Same sizing as sizeFor, with this account's own stop and target
sizeAcct(atrD, pv, mt, comm, commM, ratio, mtM, bool forceFull, float stopU, float tgtU) =>
micro = not forceFull and stopU < 0.75 * pv * atrFrac * atrD
p = micro ? pv / ratio : pv
cap = micro ? maxC * ratio : maxC
tk = micro ? mtM : mt
cst = micro ? costUsdM : costUsd
cm = micro ? commM : comm
n = math.max(1, math.min(cap, math.round(stopU / (p * atrFrac * atrD))))
sp = math.floor(math.max(stopU - cst * n, 0) / (n * p) / tk + 1e-6) * tk
tp = math.ceil((tgtU + cm * n) / (n * p) / tk - 1e-6) * tk
[n, sp, tp, sp * n * p, tp * n * p, micro]
var table tAcc = table.new(position.bottom_right, 13, 11, bgcolor = color.new(color.black, 15), border_width = 1)
if barstate.islast and showAcct
hdr2 = array.from("#", "Account", "Market", "Stage", "Side", "Entry (ET)", "Stop $ (room)", "Target $", "Contracts", "Stop (pts)", "Target (pts)", "Reward : risk", "Note")
for i = 0 to 12
table.cell(tAcc, i, 0, hdr2.get(i), text_color = color.white, bgcolor = color.new(color.gray, 60), text_size = size.small)
for k = 0 to 9
r = k + 1
mk = aMkt.get(k)
if mk == "Off"
table.cell(tAcc, 0, r, str.tostring(r), text_color = color.gray, text_size = size.small)
for c = 1 to 12
table.cell(tAcc, c, r, "", text_size = size.small)
else
bal = aBal.get(k)
flr = aFlr.get(k)
room = bal - flr
isF = aStg.get(k) == "Funded"
float tgtU = na
bool eligible = false
string note = ""
if not isF
tgtU := aTgt.get(k) - bal
else
W = aPay.get(k) == 1 ? 2000.0 : 2500.0
c0 = aC0.get(k)
bst = aBest.get(k)
thrB = 52100.0 + W
needF = math.max(thrB - c0, 500.0, bst / 0.4)
rem = c0 + needF - bal
cyc = bal - c0
eligible := bal >= thrB and cyc >= 500.0 and bst <= 0.4 * cyc
tgtU := math.max(math.min(0.4 * needF, rem), 50.0)
note := "payout " + str.tostring(aPay.get(k)) + " at " + usd(c0 + needF) + (bst / 0.4 > thrB - c0 ? " (set by the 40% rule)" : "")
float stopU = room
if not isF and acctEnd and tgtU > 0 and tgtU <= endThr
stopU := math.min(room, tgtU)
note := "endgame: 1:1 stop"
bool bad = true
if bal <= 0 or flr <= 0
note := "enter balance and drawdown limit"
else if room < 50
note := "no room left: account is done"
else if not isF and room > 2000.5
note := "room over $2,000: check balance / limit"
else if not isF and tgtU <= 0
note := "target reached: passed"
else if isF and eligible
note := "PAYOUT ELIGIBLE: request the payout, no trade"
else
bad := false
int side = mk == "Gold" ? goldDir : mk == "NQ" ? nqDir : clDir
string ent = mk == "Gold" ? "8:21" : mk == "Crude" ? "9:01" : mk == "Nat gas" ? "6:01 pm (prev. eve)" : nqEntry
int n = 0
float sp = na
float tp = na
float rU = na
float wU = na
bool mic = false
if not bad
if mk == "Gold"
[n1, s1, t1, r1, w1, m1] = sizeAcct(gcAtr, gcPv, gcMt, gcComm, gcCommM, 10, gcMt, false, stopU, tgtU)
n := n1
sp := s1
tp := t1
rU := r1
wU := w1
mic := m1
else if mk == "Crude"
[n1, s1, t1, r1, w1, m1] = sizeAcct(clAtr, clPv, clMt, clComm, clCommM, 10, clMt, false, stopU, tgtU)
n := n1
sp := s1
tp := t1
rU := r1
wU := w1
mic := m1
else if mk == "NQ"
[n1, s1, t1, r1, w1, m1] = sizeAcct(nqAtr, nqPv, nqMt, nqComm, nqCommM, 10, nqMt, nqFull, stopU, tgtU)
n := n1
sp := s1
tp := t1
rU := r1
wU := w1
mic := m1
else
[n1, s1, t1, r1, w1, m1] = sizeAcct(ngAtr, ngPv, ngMt, ngComm, ngCommM, 4, 0.005, false, stopU, tgtU)
n := n1
sp := s1
tp := t1
rU := r1
wU := w1
mic := m1
sfx = not mic ? "" : mk == "Gold" ? " MGC" : mk == "Crude" ? " MCL" : mk == "NQ" ? " MNQ" : " QG"
txt = bad ? color.gray : color.white
table.cell(tAcc, 0, r, str.tostring(r), text_color = color.white, text_size = size.small)
table.cell(tAcc, 1, r, aName.get(k), text_color = color.white, text_size = size.small)
table.cell(tAcc, 2, r, mk, text_color = color.white, text_size = size.small)
table.cell(tAcc, 3, r, aStg.get(k), text_color = isF ? color.aqua : color.white, text_size = size.small)
table.cell(tAcc, 4, r, bad ? "-" : sideText(side), text_color = bad ? color.gray : sideColor(side), text_size = size.small)
table.cell(tAcc, 5, r, bad ? "-" : ent, text_color = txt, text_size = size.small)
table.cell(tAcc, 6, r, bad ? "-" : usd(stopU), text_color = bad ? color.gray : color.red, text_size = size.small)
table.cell(tAcc, 7, r, bad ? "-" : usd(tgtU), text_color = bad ? color.gray : color.lime, text_size = size.small)
table.cell(tAcc, 8, r, bad ? "-" : str.tostring(n) + sfx, text_color = mic ? color.yellow : txt, text_size = size.small)
table.cell(tAcc, 9, r, bad ? "-" : pts(sp), text_color = bad ? color.gray : color.new(color.red, 40), text_size = size.small)
table.cell(tAcc, 10, r, bad ? "-" : pts(tp), text_color = bad ? color.gray : color.new(color.lime, 40), text_size = size.small)
table.cell(tAcc, 11, r, bad or na(rU) or rU <= 0 ? "-" : str.tostring(wU / rU, "#.##") + " : 1", text_color = txt, text_size = size.small)
table.cell(tAcc, 12, r, note, text_color = bad ? color.orange : color.new(color.white, 30), text_size = size.small)
// ---------- alerts (set to "Once Per Bar") ---------- // ---------- alerts (set to "Once Per Bar") ----------
goldNew = goldDir != 0 and nz(goldDir[1]) == 0 goldNew = goldDir != 0 and nz(goldDir[1]) == 0
nqNew = nqDir != 0 and nz(nqDir[1]) == 0 nqNew = nqDir != 0 and nz(nqDir[1]) == 0