asdf
This commit is contained in:
1 parent
bc2bb6ddcd
commit
15aa6397e8
4 files changed
+67
-57
No files matched your search
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
max payout requires 54100
|
||||
|
||||
40% consistency of each day
|
||||
|
||||
example:
|
||||
* 1640 = 51640
|
||||
* 1640 = 53280
|
||||
* 820 = 54100
|
||||
|
||||
then withdraw $2000 which leaves balance at 52100
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
// Above -> SHORT, below -> LONG.
|
||||
// Sizing: contracts = round(stop $ / ($ per point x 0.20 x daily ATR(14))), min 1, max 4;
|
||||
// stop pts = (stop $ - $20 x contracts) / (contracts x $ per point); target pts = (target $ + commission x contracts) / (contracts x $ per point).
|
||||
// Use a 1-MINUTE chart of any CME futures symbol with the full electronic session.
|
||||
// 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).
|
||||
// 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 $.
|
||||
// Signals lock when the decision candle closes (gold: 8:19 candle, NQ: 9:30 candle); until then the side shows "waiting".
|
||||
// Set alerts to "Once Per Bar Close".
|
||||
// Signals lock the moment the decision candle has closed (gold: 8:19 candle -> shown from 8:20; NQ: 9:30 candle -> from 9:31),
|
||||
// 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).
|
||||
indicator("Bracket Morning Panel", overlay = false) // own pane below the chart, so the table never covers price
|
||||
|
||||
tz = "America/New_York"
|
||||
@@ -47,11 +48,15 @@ ngComm = input.float(4.00, "Natural gas", step = 0.1, group = grpF, display = di
|
||||
// ---------- helpers (evaluated in each symbol's own context via request.security) ----------
|
||||
endsAt(h, m) => hour(time_close, tz) == h and minute(time_close, tz) == m
|
||||
|
||||
moveSinceOpen() =>
|
||||
goldMove() =>
|
||||
var float o = na
|
||||
var float m819 = na
|
||||
if timeframe.change("D") // CME trading day starts at the 6:00 pm ET reopen
|
||||
o := open
|
||||
close / o - 1.0
|
||||
m819 := na
|
||||
if endsAt(8, 21) and not na(o) // 8:20 candle: close[1] is the final close of the 8:19 candle
|
||||
m819 := close[1] / o - 1.0
|
||||
[m819, close / o - 1.0] // [move to the 8:19 close (locked), move so far (live)]
|
||||
|
||||
nqSignal() =>
|
||||
var float c16 = na
|
||||
@@ -60,12 +65,14 @@ nqSignal() =>
|
||||
var int dir = 0
|
||||
if timeframe.change("D")
|
||||
dir := 0
|
||||
if endsAt(9, 31) and not na(c16) // the 9:30 one-minute candle has just closed
|
||||
ref := na
|
||||
px := na
|
||||
if endsAt(9, 32) and not na(c16) // 9:31 candle: close[1] is the final close of the 9:30 candle
|
||||
ref := c16
|
||||
px := close
|
||||
dir := close > c16 ? -1 : 1
|
||||
if endsAt(16, 0) // the 3:59 candle: today's 4:00 pm close, used tomorrow
|
||||
c16 := close
|
||||
px := close[1]
|
||||
dir := close[1] > c16 ? -1 : 1
|
||||
if endsAt(16, 1) // 4:00 candle: close[1] is the final 3:59 close (today's 4:00 pm close, used tomorrow)
|
||||
c16 := close[1]
|
||||
[dir, ref, px]
|
||||
|
||||
clSignal() =>
|
||||
@@ -82,12 +89,12 @@ clSignal() =>
|
||||
dirNext := 0
|
||||
c901 := na
|
||||
settle := na
|
||||
if endsAt(9, 1) // close of the 9:00 candle
|
||||
c901 := close
|
||||
if endsAt(14, 30) and not na(c901) // close of the 2:29 candle = 2:30 pm settlement time
|
||||
settle := close
|
||||
dirNext := close > c901 ? -1 : 1
|
||||
[dirToday, yOpen, ySettle]
|
||||
if endsAt(9, 2) // 9:01 candle: close[1] is the final close of the 9:00 candle
|
||||
c901 := close[1]
|
||||
if endsAt(14, 31) and not na(c901) // 2:30 candle: close[1] is the final close of the 2:29 candle (2:30 pm settlement time)
|
||||
settle := close[1]
|
||||
dirNext := close[1] > c901 ? -1 : 1
|
||||
[dirToday, yOpen, ySettle, endsAt(9, 2), endsAt(18, 2)] // last two: crude entry minute (9:01), NG entry minute (6:01 pm)
|
||||
|
||||
dailyInfo() => [ta.atr(14)[1], syminfo.pointvalue, syminfo.mintick] // yesterday's ATR, completed days only
|
||||
|
||||
@@ -98,52 +105,42 @@ sizeFor(atrD, pv, mt, comm) =>
|
||||
[n, sp, tp, sp * n * pv, tp * n * pv] // last two: what to type as Risk USD / Reward USD (whole position)
|
||||
|
||||
// ---------- data ----------
|
||||
gMove = request.security(gcSym, timeframe.period, moveSinceOpen())
|
||||
sMove = request.security(siSym, timeframe.period, moveSinceOpen())
|
||||
[nqDir, nqRef, nqPx] = request.security(nqSym, timeframe.period, nqSignal())
|
||||
[clDir, clOpen, clSettle] = request.security(clSym, timeframe.period, clSignal())
|
||||
[g819, gLive] = request.security(gcSym, "1", goldMove())
|
||||
[s819, sLive] = request.security(siSym, "1", goldMove())
|
||||
[nqDir, nqRef, nqPx] = request.security(nqSym, "1", nqSignal())
|
||||
[clDir, clOpen, clSettle, clEntryNow, ngEntryNow] = request.security(clSym, "1", clSignal())
|
||||
|
||||
[gcAtr, gcPv, gcMt] = request.security(gcSym, "D", dailyInfo(), lookahead = barmerge.lookahead_on)
|
||||
[clAtr, clPv, clMt] = request.security(clSym, "D", dailyInfo(), lookahead = barmerge.lookahead_on)
|
||||
[nqAtr, nqPv, nqMt] = request.security(nqSym, "D", dailyInfo(), lookahead = barmerge.lookahead_on)
|
||||
[ngAtr, ngPv, ngMt] = request.security(ngSym, "D", dailyInfo(), lookahead = barmerge.lookahead_on)
|
||||
|
||||
// ---------- gold decision at the bar that closes 8:20 ET (the 8:19 candle) ----------
|
||||
gap = (sMove - gMove) * 100.0
|
||||
isGoldDecision = endsAt(8, 20)
|
||||
// ---------- gold decision: once per trading day, as soon as both locked 8:19 moves exist ----------
|
||||
gap = (sLive - gLive) * 100.0 // live, for the "now" display
|
||||
gap819 = (s819 - g819) * 100.0 // final, from the closed 8:19 candles
|
||||
|
||||
var array<float> hist = array.new<float>()
|
||||
var float thr = thrInput
|
||||
var float goldGap = na
|
||||
var int goldDir = 0
|
||||
var bool liveMed = false
|
||||
var bool goldDone = false
|
||||
|
||||
if timeframe.change("D")
|
||||
goldDir := 0
|
||||
goldGap := na
|
||||
goldDone := false
|
||||
|
||||
if isGoldDecision and not na(gap) and barstate.isconfirmed // only once the 8:19 candle has closed: no flicker
|
||||
if not goldDone and not na(gap819)
|
||||
liveMed := hist.size() >= minDays
|
||||
thr := liveMed ? hist.median() : thrInput // prior days only: no look-ahead
|
||||
goldGap := gap
|
||||
goldDir := gap > thr ? 1 : -1
|
||||
hist.push(math.abs(gap))
|
||||
goldGap := gap819
|
||||
goldDir := gap819 > thr ? 1 : -1
|
||||
goldDone := true
|
||||
hist.push(math.abs(gap819))
|
||||
if hist.size() > lookback
|
||||
hist.shift()
|
||||
|
||||
// ---------- NQ decision, locked at the close of the 9:30 candle ----------
|
||||
var int nqShow = 0
|
||||
var float nqShowRef = na
|
||||
var float nqShowPx = na
|
||||
if timeframe.change("D")
|
||||
nqShow := 0
|
||||
nqShowRef := na
|
||||
nqShowPx := na
|
||||
if barstate.isconfirmed and nqDir != 0 and nqShow == 0
|
||||
nqShow := nqDir
|
||||
nqShowRef := nqRef
|
||||
nqShowPx := nqPx
|
||||
|
||||
// ---------- sizing ----------
|
||||
[gcN, gcSp, gcTp, gcRiskUsd, gcRewUsd] = sizeFor(gcAtr, gcPv, gcMt, gcComm)
|
||||
[clN, clSp, clTp, clRiskUsd, clRewUsd] = sizeFor(clAtr, clPv, clMt, clComm)
|
||||
@@ -167,7 +164,7 @@ if barstate.islast
|
||||
table.cell(t, 1, 1, "8:21", text_color = color.white)
|
||||
table.cell(t, 2, 1, sideText(goldDir), text_color = sideColor(goldDir))
|
||||
table.cell(t, 3, 1, "gap " + num(goldGap) + "% vs " + num(thr) + "%" + (liveMed ? " (live median)" : " (input)") + " | now " + num(gap) + "%", text_color = color.white)
|
||||
table.cell(t, 4, 1, pts(gcAtr), text_color = color.white)
|
||||
table.cell(t, 4, 1, num(gcAtr), text_color = color.white)
|
||||
table.cell(t, 5, 1, num(gcN), text_color = color.white)
|
||||
table.cell(t, 6, 1, usd(gcRiskUsd), text_color = color.red)
|
||||
table.cell(t, 7, 1, usd(gcRewUsd), text_color = color.lime)
|
||||
@@ -178,7 +175,7 @@ if barstate.islast
|
||||
table.cell(t, 1, 2, "9:01", text_color = color.white)
|
||||
table.cell(t, 2, 2, sideText(clDir), text_color = sideColor(clDir))
|
||||
table.cell(t, 3, 2, "yesterday: settle " + num(clSettle) + " vs 9:00 close " + num(clOpen), text_color = color.white)
|
||||
table.cell(t, 4, 2, pts(clAtr), text_color = color.white)
|
||||
table.cell(t, 4, 2, num(clAtr), text_color = color.white)
|
||||
table.cell(t, 5, 2, num(clN), text_color = color.white)
|
||||
table.cell(t, 6, 2, usd(clRiskUsd), text_color = color.red)
|
||||
table.cell(t, 7, 2, usd(clRewUsd), text_color = color.lime)
|
||||
@@ -189,7 +186,7 @@ if barstate.islast
|
||||
table.cell(t, 1, 3, "6:01 pm (prev. eve)", text_color = color.white)
|
||||
table.cell(t, 2, 3, sideText(clDir), text_color = sideColor(clDir))
|
||||
table.cell(t, 3, 3, "crude's side for the trading day that opens at 6 pm (no hedging)", text_color = color.white)
|
||||
table.cell(t, 4, 3, pts(ngAtr), text_color = color.white)
|
||||
table.cell(t, 4, 3, num(ngAtr), text_color = color.white)
|
||||
table.cell(t, 5, 3, num(ngN), text_color = color.white)
|
||||
table.cell(t, 6, 3, usd(ngRiskUsd), text_color = color.red)
|
||||
table.cell(t, 7, 3, usd(ngRewUsd), text_color = color.lime)
|
||||
@@ -198,25 +195,27 @@ if barstate.islast
|
||||
|
||||
table.cell(t, 0, 4, "NQ", text_color = color.white)
|
||||
table.cell(t, 1, 4, "9:31", text_color = color.white)
|
||||
table.cell(t, 2, 4, sideText(nqShow), text_color = sideColor(nqShow))
|
||||
table.cell(t, 3, 4, "9:30 close " + num(nqShowPx) + " vs prior 4:00 close " + num(nqShowRef), text_color = color.white)
|
||||
table.cell(t, 4, 4, pts(nqAtr), text_color = color.white)
|
||||
table.cell(t, 2, 4, sideText(nqDir), text_color = sideColor(nqDir))
|
||||
table.cell(t, 3, 4, "9:30 close " + num(nqPx) + " vs prior 4:00 close " + num(nqRef), text_color = color.white)
|
||||
table.cell(t, 4, 4, num(nqAtr), text_color = color.white)
|
||||
table.cell(t, 5, 4, num(nqN), text_color = color.white)
|
||||
table.cell(t, 6, 4, usd(nqRiskUsd), text_color = color.red)
|
||||
table.cell(t, 7, 4, usd(nqRewUsd), text_color = color.lime)
|
||||
table.cell(t, 8, 4, pts(nqSp), text_color = color.new(color.red, 40))
|
||||
table.cell(t, 9, 4, pts(nqTp), text_color = color.new(color.lime, 40))
|
||||
|
||||
note = timeframe.period != "1" ? "Switch the chart to 1 minute." : "USD amounts include costs (stop: slippage + commission; target: commission): type as shown. Per-account sizes: tracker. Skip holidays and early closes."
|
||||
table.cell(t, 0, 5, note, text_color = timeframe.period != "1" ? color.orange : color.new(color.white, 30), text_size = size.small)
|
||||
note = "USD amounts include costs (stop: slippage + commission; target: commission): type as shown. Per-account sizes: tracker. Skip holidays and early closes."
|
||||
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)
|
||||
|
||||
// ---------- alerts ----------
|
||||
alertcondition(isGoldDecision and barstate.isconfirmed and goldDir == 1, "Gold LONG", "Gold bracket LONG at 8:21 ET")
|
||||
alertcondition(isGoldDecision and barstate.isconfirmed and goldDir == -1, "Gold SHORT", "Gold bracket SHORT at 8:21 ET")
|
||||
alertcondition(endsAt(9, 0) and clDir == 1, "Crude LONG", "Crude bracket LONG at 9:01 ET")
|
||||
alertcondition(endsAt(9, 0) and clDir == -1, "Crude SHORT", "Crude bracket SHORT at 9:01 ET")
|
||||
alertcondition(endsAt(18, 1) and barstate.isconfirmed and clDir == 1, "Nat gas LONG", "Nat gas bracket LONG at 6:01 pm ET for the next trading day (same side as crude)")
|
||||
alertcondition(endsAt(18, 1) and barstate.isconfirmed and clDir == -1, "Nat gas SHORT", "Nat gas bracket SHORT at 6:01 pm ET for the next trading day (same side as crude)")
|
||||
alertcondition(endsAt(9, 31) and barstate.isconfirmed and nqDir == 1, "NQ LONG", "NQ bracket LONG at 9:31 ET")
|
||||
alertcondition(endsAt(9, 31) and barstate.isconfirmed and nqDir == -1, "NQ SHORT", "NQ bracket SHORT at 9:31 ET")
|
||||
// ---------- alerts (set to "Once Per Bar") ----------
|
||||
goldNew = goldDir != 0 and nz(goldDir[1]) == 0
|
||||
nqNew = nqDir != 0 and nz(nqDir[1]) == 0
|
||||
alertcondition(goldNew and goldDir == 1, "Gold LONG", "Gold bracket LONG at 8:21 ET")
|
||||
alertcondition(goldNew and goldDir == -1, "Gold SHORT", "Gold bracket SHORT at 8:21 ET")
|
||||
alertcondition(clEntryNow and clDir == 1, "Crude LONG", "Crude bracket LONG at 9:01 ET")
|
||||
alertcondition(clEntryNow and clDir == -1, "Crude SHORT", "Crude bracket SHORT at 9:01 ET")
|
||||
alertcondition(ngEntryNow and clDir == 1, "Nat gas LONG", "Nat gas bracket LONG at 6:01 pm ET for the next trading day (same side as crude)")
|
||||
alertcondition(ngEntryNow and clDir == -1, "Nat gas SHORT", "Nat gas bracket SHORT at 6:01 pm ET for the next trading day (same side as crude)")
|
||||
alertcondition(nqNew and nqDir == 1, "NQ LONG", "NQ bracket LONG at 9:31 ET")
|
||||
alertcondition(nqNew and nqDir == -1, "NQ SHORT", "NQ bracket SHORT at 9:31 ET")
|
||||
Binary file not shown.
Reference in new issue
Block a user