Opening Range Breakout Indicator for ThinkorSwim

Sorry it is late and my notes were mixed lol.. that's what getting old does to ya! I asked Chat GPT to "clean this up" so it is what it is lol... but on review everything is there except notes that there are some manual inputs that need to be placed like what Gamma phase is it in either short gamma or long gamma or transition (1, -1, 0) and other inputs are gamma zones, which are usually gamma high volumes or if using Open Interest high bars strike prices like in Barchart.com Gamma charts. What follows is an explanation of the script and interpretation of the attached chart using this script. This script was developed in reviewing ORB studies and scripts from TOS, TradingView and NinjaTrader.

This is an excellent example — not just of the script working, but of how to think like a professional intraday trader using structure + flow + regime.
I’ll break this down as a training walkthrough so someone else could literally follow this step-by-step.

🧠 1. THE FOUNDATION: WHAT THIS SYSTEM IS DOING

This script combines 5 layers of edge:

1. Gamma (Context)​

  • Tells you: trend vs mean reversion environment
2. Levels (Structure)
  • Reclaim level (640)
  • Fade zones (643–645, 648–650)

3. Timing (Execution)​

  • First touch (FZ1)
  • Trap detection

4. Confirmation (Participation)​

  • VWAP
  • ORB breaks

5. Decision Engine​

  • Score
  • Bias
  • Market state (your new label)

📊 2. WHAT HAPPENED ON THIS CHART (STEP-BY-STEP)​


Let’s walk through this like a replay.

🔴 PHASE 1 — OPEN → INITIAL TREND​

  • Price starts below reclaim (640)
  • Gamma = SHORT (trend mode)
👉 Immediate implication: Sell rallies, not buy dips


🟡 PHASE 2 — FIRST OPPORTUNITY (FZ1 TAGS)​


You see multiple:
  • FZ1 bubbles (yellow)
👉 This is critical:


These are: First touch of resistance inside short gamma

✔ This is your highest probability short entry


What should happen (and did):​

  • Price enters 643–645
  • Momentum slows
  • Sellers step in
  • Price rolls over

👉 This is your A+ setup


🔴 PHASE 3 — TRAP FORMATION (MOST IMPORTANT)​


You see:
  • Multiple TRAP DN labels near 640

What this means:​

  1. Price tries to reclaim 640
  2. Fails
  3. Closes back below
👉 This is: FAILED BREAKOUT → CONTINUATION SIGNAL


Why this matters:​


In short gamma:
  • Dealers sell weakness
  • Failed reclaim = fuel for downside

👉 This is the strongest signal in your system

🔻 PHASE 4 — ORB CONFIRMATION

You see:
  • ORB DN signals

Combined with:
  • Price below VWAP
👉 This confirms: Trend is real, not random


🔥 PHASE 5 — TREND ACCELERATION​


After:
  • FZ1 rejection
  • Trap confirmation
  • ORB break

👉 Market transitions into: STRUCTURED TREND DOWN

You see:
  • Clean lower highs
  • Clean lower lows
  • No reclaim of key levels
⚠️ PHASE 6 — LATE TREND (KEY LESSON)

Now your label shows: LATE TREND / LOW EDGE

This is crucial training insight.

Why?​


Because:
  • Move already extended
  • Far from reclaim (640)
  • No new structure formed
  • Score = weak (-2)
👉 Meaning: The opportunity already happened


🧭 3. HOW A PROFESSIONAL TRADES THIS​


✅ What they DO​

Early:
  • Short FZ1 (643–645)
  • Add on trap near 640
  • Hold through ORB break

Mid-trend:​

  • Trail position
  • Take partial profits

Late trend (your current chart):​

  • STOP initiating new trades
  • Wait for reset

❌ What they DON’T do​

  • Chase breakdown at 633
  • Short randomly because “it’s going down”
  • Ignore “NO TRADE” signal

🧠 4. WHAT EACH COMPONENT TAUGHT YOU​


🔵 Gamma Mode​




Answer: Trend


🟡 Fade Zones​




Answer: 643–645 (FZ1)


🔴 Trap Detection​




Answer: Fake → short


🟢 ORB + VWAP​




Answer: Yes → hold trade


⚠️ Market State Label​




Answer: No → late trend

🔥 5. THE BIG LESSON (MOST IMPORTANT)​


This chart demonstrates:

The edge is NOT in predicting direction
The edge is in timing + location + context


🧠 6. SIMPLE RULESET (FOR TRAINING)​


If someone is learning this system, give them this:


🔴 SHORT GAMMA PLAYBOOK​


Step 1 — Identify regime​

  • Below flip → trend mode

Step 2 — Wait for location​

  • Fade zones (FZ1 / FZ2)

Step 3 — Confirm weakness​

  • Trap signal
  • Rejection

Step 4 — Confirm trend​

  • Below VWAP
  • ORB break

Step 5 — Manage trade​

  • Hold through structure
  • Exit when:
    • Late trend label appears
    • Score weakens

⚠️ 7. WHY THIS SYSTEM WORKS​


Because it aligns:
  • Dealer flows (gamma)
  • Liquidity (levels)
  • Behavior (traps)
  • Participation (VWAP/ORB)

👉 That’s how institutions think


🧭 FINAL SUMMARY​


This chart is a perfect training example of:

✔ Ideal short setup:​

  • FZ1 entry
  • Trap confirmation
  • ORB + VWAP alignment
✔ Ideal hold:
  • Trend continuation

✔ Ideal stop trading:​

  • Late trend label
Code:
# Gamma Edge Execution System
# Developed by antwerks
# 03/29/2026
#=================================


# ================================
# === USER INPUTS ===============
# ================================
input showLabel = yes;
input gammaMode = 1; # 1 = Short Gamma, -1 = Long Gamma

input reclaimLevel = 640;
input fadeZone1Low = 643;
input fadeZone1High = 645;
input fadeZone2Low = 648;
input fadeZone2High = 650;

input orbStartTime = 0930;
input orbEndTime   = 1000;

# ================================
# === YESTERDAY LEVELS ===========
# ================================
def yHigh = high(period = "DAY")[1];
def yLow = low(period = "DAY")[1];

plot YH = yHigh;
YH.SetDefaultColor(Color.GREEN);
YH.SetStyle(Curve.SHORT_DASH);

plot YL = yLow;
YL.SetDefaultColor(Color.RED);
YL.SetStyle(Curve.SHORT_DASH);

# ================================
# === RECLAIM LEVEL ==============
# ================================
plot Reclaim = reclaimLevel;
Reclaim.SetDefaultColor(Color.WHITE);
Reclaim.SetLineWeight(2);
Reclaim.SetStyle(Curve.SHORT_DASH);

# ================================
# === GAMMA MODE COLORS ==========
# ================================
def isShortGamma = gammaMode == 1;

DefineGlobalColor("FZ1", if isShortGamma then Color.RED else Color.LIGHT_GRAY);
DefineGlobalColor("FZ2", if isShortGamma then Color.ORANGE else Color.GRAY);

# ================================
# === FADE ZONES ================
# ================================
plot FZ1L = fadeZone1Low;
plot FZ1H = fadeZone1High;
plot FZ2L = fadeZone2Low;
plot FZ2H = fadeZone2High;

FZ1L.SetDefaultColor(GlobalColor("FZ1"));
FZ1H.SetDefaultColor(GlobalColor("FZ1"));

FZ2L.SetDefaultColor(GlobalColor("FZ2"));
FZ2H.SetDefaultColor(GlobalColor("FZ2"));

AddCloud(FZ1L, FZ1H, GlobalColor("FZ1"), GlobalColor("FZ1"));
AddCloud(FZ2L, FZ2H, GlobalColor("FZ2"), GlobalColor("FZ2"));

# ================================
# === FIRST TOUCH DETECTION ======
# ================================
def inFZ1 = close >= fadeZone1Low and close <= fadeZone1High;
def inFZ2 = close >= fadeZone2Low and close <= fadeZone2High;

def firstTouchFZ1 = inFZ1 and !inFZ1[1];
def firstTouchFZ2 = inFZ2 and !inFZ2[1];

AddChartBubble(firstTouchFZ1, high, "FZ1", Color.YELLOW, yes);
AddChartBubble(firstTouchFZ2, high, "FZ2", Color.ORANGE, yes);

# ================================
# === TRAP DETECTION ============
# ================================
def aboveReclaim = close > reclaimLevel;
def belowReclaim = close < reclaimLevel;

def wasAbove = aboveReclaim[1];

def rejection = high > reclaimLevel and close < reclaimLevel;
def strongReject = close < open;

def trapShort = wasAbove and rejection and strongReject;

AddChartBubble(trapShort and !trapShort[1], high, "TRAP DN", Color.RED, yes);

# ================================
# === VWAP ======================
# ================================
plot VWAPLine = VWAP();
VWAPLine.SetDefaultColor(Color.CYAN);
VWAPLine.SetLineWeight(2);

def aboveVWAP = close > VWAPLine;
def belowVWAP = close < VWAPLine;

# ================================
# === ORB (TIME-BASED, FIXED) ====
# ================================

def newDay = GetYYYYMMDD() <> GetYYYYMMDD()[1];
def inORB = SecondsFromTime(orbStartTime) >= 0 and SecondsTillTime(orbEndTime) > 0;
def orbFinished = SecondsTillTime(orbEndTime) <= 0;

rec orbHigh =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbHigh[1]) then high
    else if inORB then Max(high, orbHigh[1])
    else orbHigh[1];

rec orbLow =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbLow[1]) then low
    else if inORB then Min(low, orbLow[1])
    else orbLow[1];

plot ORB_High_Line = if orbFinished then orbHigh else Double.NaN;
ORB_High_Line.SetDefaultColor(Color.GREEN);
ORB_High_Line.SetStyle(Curve.SHORT_DASH);
ORB_High_Line.SetLineWeight(2);

plot ORB_Low_Line = if orbFinished then orbLow else Double.NaN;
ORB_Low_Line.SetDefaultColor(Color.RED);
ORB_Low_Line.SetStyle(Curve.SHORT_DASH);
ORB_Low_Line.SetLineWeight(2);

def breakAboveORB = orbFinished and close > orbHigh;
def breakBelowORB = orbFinished and close < orbLow;

AddChartBubble(breakAboveORB and !breakAboveORB[1], low, "ORB UP", Color.GREEN, no);
AddChartBubble(breakBelowORB and !breakBelowORB[1], high, "ORB DN", Color.RED, yes);
# ================================
# === CONFIRMATION LOGIC ========
# ================================
def trendConfirmedShort = belowVWAP and breakBelowORB;
def trendConfirmedLong = aboveVWAP and breakAboveORB;

# ================================
# === SCORING ===================
# ================================
def avgVol = Average(volume, 20);
def highVol = volume > avgVol * 1.2;

def bull = close > open;
def bear = close < open;

def bullScore =
    (if highVol then 2 else 1) +
    (if bull then 2 else 0);

def bearScore =
    (if highVol then 2 else 1) +
    (if bear then 2 else 0);

def netScore = bullScore - bearScore;

# ================================
# === LABELS ====================
# ================================
AddLabel(yes,
    if gammaMode == 1 then "Gamma: SHORT (Trend Mode)"
    else "Gamma: LONG (Mean Reversion)",
    if gammaMode == 1 then Color.CYAN else Color.ORANGE
);

AddLabel(showLabel,
    "Score: " + netScore +
    if netScore >= 4 then " (LONG)"
    else if netScore <= -4 then " (SHORT)"
    else " (NO TRADE)",
    if netScore >= 2 then Color.GREEN
    else if netScore <= -2 then Color.RED
    else Color.GRAY
);

def noTrade = AbsValue(netScore) <= 2;

AddLabel(yes,
    if noTrade then "NO TRADE"
    else "ACTIVE",
    if noTrade then Color.GRAY else Color.WHITE
);

AddLabel(yes,
    if trendConfirmedShort then "CONFIRMED SHORT (ORB + VWAP)"
    else if trendConfirmedLong then "CONFIRMED LONG (ORB + VWAP)"
    else "NO CONFIRMATION",
    if trendConfirmedShort then Color.RED
    else if trendConfirmedLong then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    if netScore <= -4 then "Bias: SHORT (Sell Rips)"
    else if netScore >= 4 then "Bias: LONG (Buy Dips)"
    else "Bias: NEUTRAL",
    if netScore <= -4 then Color.RED
    else if netScore >= 4 then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    "Reclaim: " + reclaimLevel +
    " | FZ1: " + fadeZone1Low + "-" + fadeZone1High +
    " | FZ2: " + fadeZone2Low + "-" + fadeZone2High,
    Color.WHITE
);

# ================================
# === MARKET STATE LABEL =========
# ================================

# Distance from reclaim (extension proxy)
def extension = AbsValue(close - reclaimLevel);

# You can tweak this threshold
input extensionThreshold = 5.0;

def isExtended = extension > extensionThreshold;

# State conditions
def strongTrend = (trendConfirmedShort or trendConfirmedLong) and AbsValue(netScore) >= 4;
def weakEnv = AbsValue(netScore) <= 2 and !trendConfirmedShort and !trendConfirmedLong;
def lateTrend = isExtended and AbsValue(netScore) <= 2 and (trendConfirmedShort[10] or trendConfirmedLong[10]);

# Label logic
AddLabel(yes,
    if strongTrend then "TREND CONFIRMED (HIGH EDGE)"
    else if lateTrend then "LATE TREND / LOW TRADING EDGE"
    else if weakEnv then "CHOP / LOW CONVICTION"
    else "TRANSITION",
   
    if strongTrend then Color.GREEN
    else if lateTrend then Color.YELLOW
    else if weakEnv then Color.GRAY
    else Color.DARK_ORANGE
);

# ================================
# === ALERTS ====================
# ================================
Alert(trapShort, "Trap Detected → Short Setup", Alert.BAR, Sound.Bell);
Is this just for SPY? How do you what "reclaim" level to use?
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I ran it through ChatGPT and created an "improved" version.
I added appropriate ### for you to make it work?

Code:
#Gamma Edge Execution System
#Developed by antwerks (Enhanced Version)
#03/29/2026
#=================================

#================================
#=== USER INPUTS ===============
#================================
input showLabel = yes;
input gammaMode = 1; # 1 = Short Gamma, -1 = Long Gamma

input reclaimLevel = 640;
input fadeZone1Low = 643;
input fadeZone1High = 645;
input fadeZone2Low = 648;
input fadeZone2High = 650;

input orbStartTime = 0930;
input orbEndTime = 1000;

input extensionThreshold = 5.0;

#================================
#=== YESTERDAY LEVELS ===========
#================================
def yHigh = high(period = "DAY")[1];
def yLow = low(period = "DAY")[1];

plot YH = yHigh;
YH.SetDefaultColor(Color.GREEN);
YH.SetStyle(Curve.SHORT_DASH);

plot YL = yLow;
YL.SetDefaultColor(Color.RED);
YL.SetStyle(Curve.SHORT_DASH);

#================================
#=== RECLAIM LEVEL ==============
#================================
plot Reclaim = reclaimLevel;
Reclaim.SetDefaultColor(Color.WHITE);
Reclaim.SetLineWeight(2);
Reclaim.SetStyle(Curve.SHORT_DASH);

#================================
#=== GAMMA MODE =================

#================================
def isShortGamma = gammaMode == 1;

DefineGlobalColor("FZ1", if isShortGamma then Color.RED else Color.LIGHT_GRAY);
DefineGlobalColor("FZ2", if isShortGamma then Color.ORANGE else Color.GRAY);

#================================
#=== FADE ZONES =================
#================================
plot FZ1L = fadeZone1Low;
plot FZ1H = fadeZone1High;
plot FZ2L = fadeZone2Low;
plot FZ2H = fadeZone2High;

FZ1L.SetDefaultColor(GlobalColor("FZ1"));
FZ1H.SetDefaultColor(GlobalColor("FZ1"));

FZ2L.SetDefaultColor(GlobalColor("FZ2"));
FZ2H.SetDefaultColor(GlobalColor("FZ2"));

AddCloud(FZ1L, FZ1H, GlobalColor("FZ1"), GlobalColor("FZ1"));
AddCloud(FZ2L, FZ2H, GlobalColor("FZ2"), GlobalColor("FZ2"));


#================================
#=== FIRST TOUCH DETECTION ======
#================================
def inFZ1 = close >= fadeZone1Low and close <= fadeZone1High;
def inFZ2 = close >= fadeZone2Low and close <= fadeZone2High;

def firstTouchFZ1 = inFZ1 and !inFZ1[1];
def firstTouchFZ2 = inFZ2 and !inFZ2[1];

AddChartBubble(firstTouchFZ1, high, "FZ1", Color.YELLOW, yes);
AddChartBubble(firstTouchFZ2, high, "FZ2", Color.ORANGE, yes);

#================================
#=== TRAP DETECTION (IMPROVED) ==
#================================
def aboveReclaim = close > reclaimLevel;
def belowReclaim = close < reclaimLevel;

def wasAbove = aboveReclaim[1];
def wasBelow = belowReclaim[1];

#Wick-based rejection
def upperWick = high - Max(open, close);
def lowerWick = Min(open, close) - low;
def body = AbsValue(close - open);

def strongRejectDown = upperWick > body * 1.5 and close < open;
def strongRejectUp = lowerWick > body * 1.5 and close > open;

def rejectionDown = high > reclaimLevel and close < reclaimLevel;
def rejectionUp = low < reclaimLevel and close > reclaimLevel;

def trapShort = wasAbove and rejectionDown and strongRejectDown;
def trapLong = wasBelow and rejectionUp and strongRejectUp;

AddChartBubble(trapShort and !trapShort[1], high, "TRAP DN", Color.RED, yes);
AddChartBubble(trapLong and !trapLong[1], low, "TRAP UP", Color.GREEN, no);

#================================
#=== VWAP =======================
#================================
plot VWAPLine = VWAP();
VWAPLine.SetDefaultColor(Color.CYAN);
VWAPLine.SetLineWeight(2);

def aboveVWAP = close > VWAPLine;
def belowVWAP = close < VWAPLine;

#================================
#=== ORB ========================
#================================
def newDay = GetYYYYMMDD() <> GetYYYYMMDD()[1];
def inORB = SecondsFromTime(orbStartTime) >= 0 and SecondsTillTime(orbEndTime) > 0;
def orbFinished = SecondsTillTime(orbEndTime) <= 0;

rec orbHigh =
if newDay then Double.NaN
else if inORB and IsNaN(orbHigh[1]) then high
else if inORB then Max(high, orbHigh[1])
else orbHigh[1];

rec orbLow =
if newDay then Double.NaN
else if inORB and IsNaN(orbLow[1]) then low
else if inORB then Min(low, orbLow[1])
else orbLow[1];

plot ORB_High_Line = if orbFinished then orbHigh else Double.NaN;
plot ORB_Low_Line = if orbFinished then orbLow else Double.NaN;

ORB_High_Line.SetDefaultColor(Color.GREEN);
ORB_Low_Line.SetDefaultColor(Color.RED);

#First break only (fixed)
def breakAboveORB = orbFinished and close > orbHigh;
def breakBelowORB = orbFinished and close < orbLow;

def firstBreakAboveORB = breakAboveORB and !breakAboveORB[1];
def firstBreakBelowORB = breakBelowORB and !breakBelowORB[1];

AddChartBubble(firstBreakAboveORB, low, "ORB UP", Color.GREEN, no);
AddChartBubble(firstBreakBelowORB, high, "ORB DN", Color.RED, yes);

#================================
#=== CONFIRMATION ===============
#================================
def trendConfirmedShort = belowVWAP and firstBreakBelowORB;
def trendConfirmedLong = aboveVWAP and firstBreakAboveORB;

#================================
#=== SCORING (IMPROVED) =========
#================================
def avgVol = Average(volume, 20);
def highVol = volume > avgVol * 1.2;

def bull = close > open;
def bear = close < open;

def bullScore =
(if highVol then 2 else 1) +
(if bull then 2 else 0);

def bearScore =
(if highVol then 2 else 1) +
(if bear then 2 else 0);

#Location factor
def locationScore =
if close > reclaimLevel then 1
else if close < reclaimLevel then -1
else 0;

def netScore = (bullScore - bearScore) + locationScore;

def noTrade = AbsValue(netScore) <= 2;

#================================
#=== MARKET STATE ===============
#================================
def extension = AbsValue(close - reclaimLevel);
def isExtended = extension > extensionThreshold;

def strongTrend = (trendConfirmedShort or trendConfirmedLong) and AbsValue(netScore) >= 4;
def weakEnv = AbsValue(netScore) <= 2 and !trendConfirmedShort and !trendConfirmedLong;
def lateTrend = isExtended and AbsValue(netScore) <= 2 and (trendConfirmedShort[10] or trendConfirmedLong[10]);

#================================
#=== LABELS =====================
#================================
AddLabel(yes,
if gammaMode == 1 then "Gamma: SHORT (Trend Mode)"
else "Gamma: LONG (Mean Reversion)",
if gammaMode == 1 then Color.CYAN else Color.ORANGE
);

AddLabel(showLabel,
"Score: " + netScore +
if netScore >= 4 then " (LONG)"
else if netScore <= -4 then " (SHORT)"
else " (NO TRADE)",
if netScore >= 2 then Color.GREEN
else if netScore <= -2 then Color.RED
else Color.GRAY
);

AddLabel(yes,
if noTrade then "NO TRADE" else "ACTIVE",
if noTrade then Color.GRAY else Color.WHITE
);

AddLabel(yes,
if strongTrend then "TREND CONFIRMED (HIGH EDGE)"
else if lateTrend then "LATE TREND"
else if weakEnv then "CHOP"
else "TRANSITION",
if strongTrend then Color.GREEN
else if lateTrend then Color.YELLOW
else if weakEnv then Color.GRAY
else Color.DARK_ORANGE
);

#================================
#=== ALERTS =====================
#================================
Alert(trapShort, "Trap Short", Alert.BAR, Sound.Bell);
Alert(trapLong, "Trap Long", Alert.BAR, Sound.Bell);
 
Last edited by a moderator:
I added appropriate ### for you to make it work?

Code:
#Gamma Edge Execution System
#Developed by antwerks (Enhanced Version)
#03/29/2026
#=================================

#================================
#=== USER INPUTS ===============
#================================
input showLabel = yes;
input gammaMode = 1; # 1 = Short Gamma, -1 = Long Gamma

input reclaimLevel = 640;
input fadeZone1Low = 643;
input fadeZone1High = 645;
input fadeZone2Low = 648;
input fadeZone2High = 650;

input orbStartTime = 0930;
input orbEndTime = 1000;

input extensionThreshold = 5.0;

#================================
#=== YESTERDAY LEVELS ===========
#================================
def yHigh = high(period = "DAY")[1];
def yLow = low(period = "DAY")[1];

plot YH = yHigh;
YH.SetDefaultColor(Color.GREEN);
YH.SetStyle(Curve.SHORT_DASH);

plot YL = yLow;
YL.SetDefaultColor(Color.RED);
YL.SetStyle(Curve.SHORT_DASH);

#================================
#=== RECLAIM LEVEL ==============
#================================
plot Reclaim = reclaimLevel;
Reclaim.SetDefaultColor(Color.WHITE);
Reclaim.SetLineWeight(2);
Reclaim.SetStyle(Curve.SHORT_DASH);

#================================
#=== GAMMA MODE =================

#================================
def isShortGamma = gammaMode == 1;

DefineGlobalColor("FZ1", if isShortGamma then Color.RED else Color.LIGHT_GRAY);
DefineGlobalColor("FZ2", if isShortGamma then Color.ORANGE else Color.GRAY);

#================================
#=== FADE ZONES =================
#================================
plot FZ1L = fadeZone1Low;
plot FZ1H = fadeZone1High;
plot FZ2L = fadeZone2Low;
plot FZ2H = fadeZone2High;

FZ1L.SetDefaultColor(GlobalColor("FZ1"));
FZ1H.SetDefaultColor(GlobalColor("FZ1"));

FZ2L.SetDefaultColor(GlobalColor("FZ2"));
FZ2H.SetDefaultColor(GlobalColor("FZ2"));

AddCloud(FZ1L, FZ1H, GlobalColor("FZ1"), GlobalColor("FZ1"));
AddCloud(FZ2L, FZ2H, GlobalColor("FZ2"), GlobalColor("FZ2"));


#================================
#=== FIRST TOUCH DETECTION ======
#================================
def inFZ1 = close >= fadeZone1Low and close <= fadeZone1High;
def inFZ2 = close >= fadeZone2Low and close <= fadeZone2High;

def firstTouchFZ1 = inFZ1 and !inFZ1[1];
def firstTouchFZ2 = inFZ2 and !inFZ2[1];

AddChartBubble(firstTouchFZ1, high, "FZ1", Color.YELLOW, yes);
AddChartBubble(firstTouchFZ2, high, "FZ2", Color.ORANGE, yes);

#================================
#=== TRAP DETECTION (IMPROVED) ==
#================================
def aboveReclaim = close > reclaimLevel;
def belowReclaim = close < reclaimLevel;

def wasAbove = aboveReclaim[1];
def wasBelow = belowReclaim[1];

#Wick-based rejection
def upperWick = high - Max(open, close);
def lowerWick = Min(open, close) - low;
def body = AbsValue(close - open);

def strongRejectDown = upperWick > body * 1.5 and close < open;
def strongRejectUp = lowerWick > body * 1.5 and close > open;

def rejectionDown = high > reclaimLevel and close < reclaimLevel;
def rejectionUp = low < reclaimLevel and close > reclaimLevel;

def trapShort = wasAbove and rejectionDown and strongRejectDown;
def trapLong = wasBelow and rejectionUp and strongRejectUp;

AddChartBubble(trapShort and !trapShort[1], high, "TRAP DN", Color.RED, yes);
AddChartBubble(trapLong and !trapLong[1], low, "TRAP UP", Color.GREEN, no);

#================================
#=== VWAP =======================
#================================
plot VWAPLine = VWAP();
VWAPLine.SetDefaultColor(Color.CYAN);
VWAPLine.SetLineWeight(2);

def aboveVWAP = close > VWAPLine;
def belowVWAP = close < VWAPLine;

#================================
#=== ORB ========================
#================================
def newDay = GetYYYYMMDD() <> GetYYYYMMDD()[1];
def inORB = SecondsFromTime(orbStartTime) >= 0 and SecondsTillTime(orbEndTime) > 0;
def orbFinished = SecondsTillTime(orbEndTime) <= 0;

rec orbHigh =
if newDay then Double.NaN
else if inORB and IsNaN(orbHigh[1]) then high
else if inORB then Max(high, orbHigh[1])
else orbHigh[1];

rec orbLow =
if newDay then Double.NaN
else if inORB and IsNaN(orbLow[1]) then low
else if inORB then Min(low, orbLow[1])
else orbLow[1];

plot ORB_High_Line = if orbFinished then orbHigh else Double.NaN;
plot ORB_Low_Line = if orbFinished then orbLow else Double.NaN;

ORB_High_Line.SetDefaultColor(Color.GREEN);
ORB_Low_Line.SetDefaultColor(Color.RED);

#First break only (fixed)
def breakAboveORB = orbFinished and close > orbHigh;
def breakBelowORB = orbFinished and close < orbLow;

def firstBreakAboveORB = breakAboveORB and !breakAboveORB[1];
def firstBreakBelowORB = breakBelowORB and !breakBelowORB[1];

AddChartBubble(firstBreakAboveORB, low, "ORB UP", Color.GREEN, no);
AddChartBubble(firstBreakBelowORB, high, "ORB DN", Color.RED, yes);

#================================
#=== CONFIRMATION ===============
#================================
def trendConfirmedShort = belowVWAP and firstBreakBelowORB;
def trendConfirmedLong = aboveVWAP and firstBreakAboveORB;

#================================
#=== SCORING (IMPROVED) =========
#================================
def avgVol = Average(volume, 20);
def highVol = volume > avgVol * 1.2;

def bull = close > open;
def bear = close < open;

def bullScore =
(if highVol then 2 else 1) +
(if bull then 2 else 0);

def bearScore =
(if highVol then 2 else 1) +
(if bear then 2 else 0);

#Location factor
def locationScore =
if close > reclaimLevel then 1
else if close < reclaimLevel then -1
else 0;

def netScore = (bullScore - bearScore) + locationScore;

def noTrade = AbsValue(netScore) <= 2;

#================================
#=== MARKET STATE ===============
#================================
def extension = AbsValue(close - reclaimLevel);
def isExtended = extension > extensionThreshold;

def strongTrend = (trendConfirmedShort or trendConfirmedLong) and AbsValue(netScore) >= 4;
def weakEnv = AbsValue(netScore) <= 2 and !trendConfirmedShort and !trendConfirmedLong;
def lateTrend = isExtended and AbsValue(netScore) <= 2 and (trendConfirmedShort[10] or trendConfirmedLong[10]);

#================================
#=== LABELS =====================
#================================
AddLabel(yes,
if gammaMode == 1 then "Gamma: SHORT (Trend Mode)"
else "Gamma: LONG (Mean Reversion)",
if gammaMode == 1 then Color.CYAN else Color.ORANGE
);

AddLabel(showLabel,
"Score: " + netScore +
if netScore >= 4 then " (LONG)"
else if netScore <= -4 then " (SHORT)"
else " (NO TRADE)",
if netScore >= 2 then Color.GREEN
else if netScore <= -2 then Color.RED
else Color.GRAY
);

AddLabel(yes,
if noTrade then "NO TRADE" else "ACTIVE",
if noTrade then Color.GRAY else Color.WHITE
);

AddLabel(yes,
if strongTrend then "TREND CONFIRMED (HIGH EDGE)"
else if lateTrend then "LATE TREND"
else if weakEnv then "CHOP"
else "TRANSITION",
if strongTrend then Color.GREEN
else if lateTrend then Color.YELLOW
else if weakEnv then Color.GRAY
else Color.DARK_ORANGE
);

#================================
#=== ALERTS =====================
#================================
Alert(trapShort, "Trap Short", Alert.BAR, Sound.Bell);
Alert(trapLong, "Trap Long", Alert.BAR, Sound.Bell);
I don't see how that makes it work for me trading other securities.
 
Sorry it is late and my notes were mixed lol.. that's what getting old does to ya! I asked Chat GPT to "clean this up" so it is what it is lol... but on review everything is there except notes that there are some manual inputs that need to be placed like what Gamma phase is it in either short gamma or long gamma or transition (1, -1, 0) and other inputs are gamma zones, which are usually gamma high volumes or if using Open Interest high bars strike prices like in Barchart.com Gamma charts. What follows is an explanation of the script and interpretation of the attached chart using this script. This script was developed in reviewing ORB studies and scripts from TOS, TradingView and NinjaTrader.

This is an excellent example — not just of the script working, but of how to think like a professional intraday trader using structure + flow + regime.
I’ll break this down as a training walkthrough so someone else could literally follow this step-by-step.

🧠 1. THE FOUNDATION: WHAT THIS SYSTEM IS DOING

This script combines 5 layers of edge:

1. Gamma (Context)​

  • Tells you: trend vs mean reversion environment
2. Levels (Structure)
  • Reclaim level (640)
  • Fade zones (643–645, 648–650)

3. Timing (Execution)​

  • First touch (FZ1)
  • Trap detection

4. Confirmation (Participation)​

  • VWAP
  • ORB breaks

5. Decision Engine​

  • Score
  • Bias
  • Market state (your new label)

📊 2. WHAT HAPPENED ON THIS CHART (STEP-BY-STEP)​


Let’s walk through this like a replay.

🔴 PHASE 1 — OPEN → INITIAL TREND​

  • Price starts below reclaim (640)
  • Gamma = SHORT (trend mode)
👉 Immediate implication: Sell rallies, not buy dips


🟡 PHASE 2 — FIRST OPPORTUNITY (FZ1 TAGS)​


You see multiple:
  • FZ1 bubbles (yellow)
👉 This is critical:


These are: First touch of resistance inside short gamma

✔ This is your highest probability short entry


What should happen (and did):​

  • Price enters 643–645
  • Momentum slows
  • Sellers step in
  • Price rolls over

👉 This is your A+ setup


🔴 PHASE 3 — TRAP FORMATION (MOST IMPORTANT)​


You see:
  • Multiple TRAP DN labels near 640

What this means:​

  1. Price tries to reclaim 640
  2. Fails
  3. Closes back below
👉 This is: FAILED BREAKOUT → CONTINUATION SIGNAL


Why this matters:​


In short gamma:
  • Dealers sell weakness
  • Failed reclaim = fuel for downside

👉 This is the strongest signal in your system

🔻 PHASE 4 — ORB CONFIRMATION

You see:
  • ORB DN signals

Combined with:
  • Price below VWAP
👉 This confirms: Trend is real, not random


🔥 PHASE 5 — TREND ACCELERATION​


After:
  • FZ1 rejection
  • Trap confirmation
  • ORB break

👉 Market transitions into: STRUCTURED TREND DOWN

You see:
  • Clean lower highs
  • Clean lower lows
  • No reclaim of key levels
⚠️ PHASE 6 — LATE TREND (KEY LESSON)

Now your label shows: LATE TREND / LOW EDGE

This is crucial training insight.

Why?​


Because:
  • Move already extended
  • Far from reclaim (640)
  • No new structure formed
  • Score = weak (-2)
👉 Meaning: The opportunity already happened


🧭 3. HOW A PROFESSIONAL TRADES THIS​


✅ What they DO​

Early:
  • Short FZ1 (643–645)
  • Add on trap near 640
  • Hold through ORB break

Mid-trend:​

  • Trail position
  • Take partial profits

Late trend (your current chart):​

  • STOP initiating new trades
  • Wait for reset

❌ What they DON’T do​

  • Chase breakdown at 633
  • Short randomly because “it’s going down”
  • Ignore “NO TRADE” signal

🧠 4. WHAT EACH COMPONENT TAUGHT YOU​


🔵 Gamma Mode​




Answer: Trend


🟡 Fade Zones​




Answer: 643–645 (FZ1)


🔴 Trap Detection​




Answer: Fake → short


🟢 ORB + VWAP​




Answer: Yes → hold trade


⚠️ Market State Label​




Answer: No → late trend

🔥 5. THE BIG LESSON (MOST IMPORTANT)​


This chart demonstrates:

The edge is NOT in predicting direction
The edge is in timing + location + context


🧠 6. SIMPLE RULESET (FOR TRAINING)​


If someone is learning this system, give them this:


🔴 SHORT GAMMA PLAYBOOK​


Step 1 — Identify regime​

  • Below flip → trend mode

Step 2 — Wait for location​

  • Fade zones (FZ1 / FZ2)

Step 3 — Confirm weakness​

  • Trap signal
  • Rejection

Step 4 — Confirm trend​

  • Below VWAP
  • ORB break

Step 5 — Manage trade​

  • Hold through structure
  • Exit when:
    • Late trend label appears
    • Score weakens

⚠️ 7. WHY THIS SYSTEM WORKS​


Because it aligns:
  • Dealer flows (gamma)
  • Liquidity (levels)
  • Behavior (traps)
  • Participation (VWAP/ORB)

👉 That’s how institutions think


🧭 FINAL SUMMARY​


This chart is a perfect training example of:

✔ Ideal short setup:​

  • FZ1 entry
  • Trap confirmation
  • ORB + VWAP alignment
✔ Ideal hold:
  • Trend continuation

✔ Ideal stop trading:​

  • Late trend label
Code:
# Gamma Edge Execution System
# Developed by antwerks
# 03/29/2026
#=================================


# ================================
# === USER INPUTS ===============
# ================================
input showLabel = yes;
input gammaMode = 1; # 1 = Short Gamma, -1 = Long Gamma

input reclaimLevel = 640;
input fadeZone1Low = 643;
input fadeZone1High = 645;
input fadeZone2Low = 648;
input fadeZone2High = 650;

input orbStartTime = 0930;
input orbEndTime   = 1000;

# ================================
# === YESTERDAY LEVELS ===========
# ================================
def yHigh = high(period = "DAY")[1];
def yLow = low(period = "DAY")[1];

plot YH = yHigh;
YH.SetDefaultColor(Color.GREEN);
YH.SetStyle(Curve.SHORT_DASH);

plot YL = yLow;
YL.SetDefaultColor(Color.RED);
YL.SetStyle(Curve.SHORT_DASH);

# ================================
# === RECLAIM LEVEL ==============
# ================================
plot Reclaim = reclaimLevel;
Reclaim.SetDefaultColor(Color.WHITE);
Reclaim.SetLineWeight(2);
Reclaim.SetStyle(Curve.SHORT_DASH);

# ================================
# === GAMMA MODE COLORS ==========
# ================================
def isShortGamma = gammaMode == 1;

DefineGlobalColor("FZ1", if isShortGamma then Color.RED else Color.LIGHT_GRAY);
DefineGlobalColor("FZ2", if isShortGamma then Color.ORANGE else Color.GRAY);

# ================================
# === FADE ZONES ================
# ================================
plot FZ1L = fadeZone1Low;
plot FZ1H = fadeZone1High;
plot FZ2L = fadeZone2Low;
plot FZ2H = fadeZone2High;

FZ1L.SetDefaultColor(GlobalColor("FZ1"));
FZ1H.SetDefaultColor(GlobalColor("FZ1"));

FZ2L.SetDefaultColor(GlobalColor("FZ2"));
FZ2H.SetDefaultColor(GlobalColor("FZ2"));

AddCloud(FZ1L, FZ1H, GlobalColor("FZ1"), GlobalColor("FZ1"));
AddCloud(FZ2L, FZ2H, GlobalColor("FZ2"), GlobalColor("FZ2"));

# ================================
# === FIRST TOUCH DETECTION ======
# ================================
def inFZ1 = close >= fadeZone1Low and close <= fadeZone1High;
def inFZ2 = close >= fadeZone2Low and close <= fadeZone2High;

def firstTouchFZ1 = inFZ1 and !inFZ1[1];
def firstTouchFZ2 = inFZ2 and !inFZ2[1];

AddChartBubble(firstTouchFZ1, high, "FZ1", Color.YELLOW, yes);
AddChartBubble(firstTouchFZ2, high, "FZ2", Color.ORANGE, yes);

# ================================
# === TRAP DETECTION ============
# ================================
def aboveReclaim = close > reclaimLevel;
def belowReclaim = close < reclaimLevel;

def wasAbove = aboveReclaim[1];

def rejection = high > reclaimLevel and close < reclaimLevel;
def strongReject = close < open;

def trapShort = wasAbove and rejection and strongReject;

AddChartBubble(trapShort and !trapShort[1], high, "TRAP DN", Color.RED, yes);

# ================================
# === VWAP ======================
# ================================
plot VWAPLine = VWAP();
VWAPLine.SetDefaultColor(Color.CYAN);
VWAPLine.SetLineWeight(2);

def aboveVWAP = close > VWAPLine;
def belowVWAP = close < VWAPLine;

# ================================
# === ORB (TIME-BASED, FIXED) ====
# ================================

def newDay = GetYYYYMMDD() <> GetYYYYMMDD()[1];
def inORB = SecondsFromTime(orbStartTime) >= 0 and SecondsTillTime(orbEndTime) > 0;
def orbFinished = SecondsTillTime(orbEndTime) <= 0;

rec orbHigh =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbHigh[1]) then high
    else if inORB then Max(high, orbHigh[1])
    else orbHigh[1];

rec orbLow =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbLow[1]) then low
    else if inORB then Min(low, orbLow[1])
    else orbLow[1];

plot ORB_High_Line = if orbFinished then orbHigh else Double.NaN;
ORB_High_Line.SetDefaultColor(Color.GREEN);
ORB_High_Line.SetStyle(Curve.SHORT_DASH);
ORB_High_Line.SetLineWeight(2);

plot ORB_Low_Line = if orbFinished then orbLow else Double.NaN;
ORB_Low_Line.SetDefaultColor(Color.RED);
ORB_Low_Line.SetStyle(Curve.SHORT_DASH);
ORB_Low_Line.SetLineWeight(2);

def breakAboveORB = orbFinished and close > orbHigh;
def breakBelowORB = orbFinished and close < orbLow;

AddChartBubble(breakAboveORB and !breakAboveORB[1], low, "ORB UP", Color.GREEN, no);
AddChartBubble(breakBelowORB and !breakBelowORB[1], high, "ORB DN", Color.RED, yes);
# ================================
# === CONFIRMATION LOGIC ========
# ================================
def trendConfirmedShort = belowVWAP and breakBelowORB;
def trendConfirmedLong = aboveVWAP and breakAboveORB;

# ================================
# === SCORING ===================
# ================================
def avgVol = Average(volume, 20);
def highVol = volume > avgVol * 1.2;

def bull = close > open;
def bear = close < open;

def bullScore =
    (if highVol then 2 else 1) +
    (if bull then 2 else 0);

def bearScore =
    (if highVol then 2 else 1) +
    (if bear then 2 else 0);

def netScore = bullScore - bearScore;

# ================================
# === LABELS ====================
# ================================
AddLabel(yes,
    if gammaMode == 1 then "Gamma: SHORT (Trend Mode)"
    else "Gamma: LONG (Mean Reversion)",
    if gammaMode == 1 then Color.CYAN else Color.ORANGE
);

AddLabel(showLabel,
    "Score: " + netScore +
    if netScore >= 4 then " (LONG)"
    else if netScore <= -4 then " (SHORT)"
    else " (NO TRADE)",
    if netScore >= 2 then Color.GREEN
    else if netScore <= -2 then Color.RED
    else Color.GRAY
);

def noTrade = AbsValue(netScore) <= 2;

AddLabel(yes,
    if noTrade then "NO TRADE"
    else "ACTIVE",
    if noTrade then Color.GRAY else Color.WHITE
);

AddLabel(yes,
    if trendConfirmedShort then "CONFIRMED SHORT (ORB + VWAP)"
    else if trendConfirmedLong then "CONFIRMED LONG (ORB + VWAP)"
    else "NO CONFIRMATION",
    if trendConfirmedShort then Color.RED
    else if trendConfirmedLong then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    if netScore <= -4 then "Bias: SHORT (Sell Rips)"
    else if netScore >= 4 then "Bias: LONG (Buy Dips)"
    else "Bias: NEUTRAL",
    if netScore <= -4 then Color.RED
    else if netScore >= 4 then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    "Reclaim: " + reclaimLevel +
    " | FZ1: " + fadeZone1Low + "-" + fadeZone1High +
    " | FZ2: " + fadeZone2Low + "-" + fadeZone2High,
    Color.WHITE
);

# ================================
# === MARKET STATE LABEL =========
# ================================

# Distance from reclaim (extension proxy)
def extension = AbsValue(close - reclaimLevel);

# You can tweak this threshold
input extensionThreshold = 5.0;

def isExtended = extension > extensionThreshold;

# State conditions
def strongTrend = (trendConfirmedShort or trendConfirmedLong) and AbsValue(netScore) >= 4;
def weakEnv = AbsValue(netScore) <= 2 and !trendConfirmedShort and !trendConfirmedLong;
def lateTrend = isExtended and AbsValue(netScore) <= 2 and (trendConfirmedShort[10] or trendConfirmedLong[10]);

# Label logic
AddLabel(yes,
    if strongTrend then "TREND CONFIRMED (HIGH EDGE)"
    else if lateTrend then "LATE TREND / LOW TRADING EDGE"
    else if weakEnv then "CHOP / LOW CONVICTION"
    else "TRANSITION",
   
    if strongTrend then Color.GREEN
    else if lateTrend then Color.YELLOW
    else if weakEnv then Color.GRAY
    else Color.DARK_ORANGE
);

# ================================
# === ALERTS ====================
# ================================
Alert(trapShort, "Trap Detected → Short Setup", Alert.BAR, Sound.Bell);
Reclaim and Fade Zones are hardcoded how can we make it dynamic for each day?
Great game plan writeup btw
 
Sorry it is late and my notes were mixed lol.. that's what getting old does to ya! I asked Chat GPT to "clean this up" so it is what it is lol... but on review everything is there except notes that there are some manual inputs that need to be placed like what Gamma phase is it in either short gamma or long gamma or transition (1, -1, 0) and other inputs are gamma zones, which are usually gamma high volumes or if using Open Interest high bars strike prices like in Barchart.com Gamma charts. What follows is an explanation of the script and interpretation of the attached chart using this script. This script was developed in reviewing ORB studies and scripts from TOS, TradingView and NinjaTrader.

This is an excellent example — not just of the script working, but of how to think like a professional intraday trader using structure + flow + regime.
I’ll break this down as a training walkthrough so someone else could literally follow this step-by-step.

🧠 1. THE FOUNDATION: WHAT THIS SYSTEM IS DOING

This script combines 5 layers of edge:

1. Gamma (Context)​

  • Tells you: trend vs mean reversion environment
2. Levels (Structure)
  • Reclaim level (640)
  • Fade zones (643–645, 648–650)

3. Timing (Execution)​

  • First touch (FZ1)
  • Trap detection

4. Confirmation (Participation)​

  • VWAP
  • ORB breaks

5. Decision Engine​

  • Score
  • Bias
  • Market state (your new label)

📊 2. WHAT HAPPENED ON THIS CHART (STEP-BY-STEP)​


Let’s walk through this like a replay.

🔴 PHASE 1 — OPEN → INITIAL TREND​

  • Price starts below reclaim (640)
  • Gamma = SHORT (trend mode)
👉 Immediate implication: Sell rallies, not buy dips


🟡 PHASE 2 — FIRST OPPORTUNITY (FZ1 TAGS)​


You see multiple:
  • FZ1 bubbles (yellow)
👉 This is critical:


These are: First touch of resistance inside short gamma

✔ This is your highest probability short entry


What should happen (and did):​

  • Price enters 643–645
  • Momentum slows
  • Sellers step in
  • Price rolls over

👉 This is your A+ setup


🔴 PHASE 3 — TRAP FORMATION (MOST IMPORTANT)​


You see:
  • Multiple TRAP DN labels near 640

What this means:​

  1. Price tries to reclaim 640
  2. Fails
  3. Closes back below
👉 This is: FAILED BREAKOUT → CONTINUATION SIGNAL


Why this matters:​


In short gamma:
  • Dealers sell weakness
  • Failed reclaim = fuel for downside

👉 This is the strongest signal in your system

🔻 PHASE 4 — ORB CONFIRMATION

You see:
  • ORB DN signals

Combined with:
  • Price below VWAP
👉 This confirms: Trend is real, not random


🔥 PHASE 5 — TREND ACCELERATION​


After:
  • FZ1 rejection
  • Trap confirmation
  • ORB break

👉 Market transitions into: STRUCTURED TREND DOWN

You see:
  • Clean lower highs
  • Clean lower lows
  • No reclaim of key levels
⚠️ PHASE 6 — LATE TREND (KEY LESSON)

Now your label shows: LATE TREND / LOW EDGE

This is crucial training insight.

Why?​


Because:
  • Move already extended
  • Far from reclaim (640)
  • No new structure formed
  • Score = weak (-2)
👉 Meaning: The opportunity already happened


🧭 3. HOW A PROFESSIONAL TRADES THIS​


✅ What they DO​

Early:
  • Short FZ1 (643–645)
  • Add on trap near 640
  • Hold through ORB break

Mid-trend:​

  • Trail position
  • Take partial profits

Late trend (your current chart):​

  • STOP initiating new trades
  • Wait for reset

❌ What they DON’T do​

  • Chase breakdown at 633
  • Short randomly because “it’s going down”
  • Ignore “NO TRADE” signal

🧠 4. WHAT EACH COMPONENT TAUGHT YOU​


🔵 Gamma Mode​




Answer: Trend


🟡 Fade Zones​




Answer: 643–645 (FZ1)


🔴 Trap Detection​




Answer: Fake → short


🟢 ORB + VWAP​




Answer: Yes → hold trade


⚠️ Market State Label​




Answer: No → late trend

🔥 5. THE BIG LESSON (MOST IMPORTANT)​


This chart demonstrates:

The edge is NOT in predicting direction
The edge is in timing + location + context


🧠 6. SIMPLE RULESET (FOR TRAINING)​


If someone is learning this system, give them this:


🔴 SHORT GAMMA PLAYBOOK​


Step 1 — Identify regime​

  • Below flip → trend mode

Step 2 — Wait for location​

  • Fade zones (FZ1 / FZ2)

Step 3 — Confirm weakness​

  • Trap signal
  • Rejection

Step 4 — Confirm trend​

  • Below VWAP
  • ORB break

Step 5 — Manage trade​

  • Hold through structure
  • Exit when:
    • Late trend label appears
    • Score weakens

⚠️ 7. WHY THIS SYSTEM WORKS​


Because it aligns:
  • Dealer flows (gamma)
  • Liquidity (levels)
  • Behavior (traps)
  • Participation (VWAP/ORB)

👉 That’s how institutions think


🧭 FINAL SUMMARY​


This chart is a perfect training example of:

✔ Ideal short setup:​

  • FZ1 entry
  • Trap confirmation
  • ORB + VWAP alignment
✔ Ideal hold:
  • Trend continuation

✔ Ideal stop trading:​

  • Late trend label
Code:
# Gamma Edge Execution System
# Developed by antwerks
# 03/29/2026
#=================================


# ================================
# === USER INPUTS ===============
# ================================
input showLabel = yes;
input gammaMode = 1; # 1 = Short Gamma, -1 = Long Gamma

input reclaimLevel = 640;
input fadeZone1Low = 643;
input fadeZone1High = 645;
input fadeZone2Low = 648;
input fadeZone2High = 650;

input orbStartTime = 0930;
input orbEndTime   = 1000;

# ================================
# === YESTERDAY LEVELS ===========
# ================================
def yHigh = high(period = "DAY")[1];
def yLow = low(period = "DAY")[1];

plot YH = yHigh;
YH.SetDefaultColor(Color.GREEN);
YH.SetStyle(Curve.SHORT_DASH);

plot YL = yLow;
YL.SetDefaultColor(Color.RED);
YL.SetStyle(Curve.SHORT_DASH);

# ================================
# === RECLAIM LEVEL ==============
# ================================
plot Reclaim = reclaimLevel;
Reclaim.SetDefaultColor(Color.WHITE);
Reclaim.SetLineWeight(2);
Reclaim.SetStyle(Curve.SHORT_DASH);

# ================================
# === GAMMA MODE COLORS ==========
# ================================
def isShortGamma = gammaMode == 1;

DefineGlobalColor("FZ1", if isShortGamma then Color.RED else Color.LIGHT_GRAY);
DefineGlobalColor("FZ2", if isShortGamma then Color.ORANGE else Color.GRAY);

# ================================
# === FADE ZONES ================
# ================================
plot FZ1L = fadeZone1Low;
plot FZ1H = fadeZone1High;
plot FZ2L = fadeZone2Low;
plot FZ2H = fadeZone2High;

FZ1L.SetDefaultColor(GlobalColor("FZ1"));
FZ1H.SetDefaultColor(GlobalColor("FZ1"));

FZ2L.SetDefaultColor(GlobalColor("FZ2"));
FZ2H.SetDefaultColor(GlobalColor("FZ2"));

AddCloud(FZ1L, FZ1H, GlobalColor("FZ1"), GlobalColor("FZ1"));
AddCloud(FZ2L, FZ2H, GlobalColor("FZ2"), GlobalColor("FZ2"));

# ================================
# === FIRST TOUCH DETECTION ======
# ================================
def inFZ1 = close >= fadeZone1Low and close <= fadeZone1High;
def inFZ2 = close >= fadeZone2Low and close <= fadeZone2High;

def firstTouchFZ1 = inFZ1 and !inFZ1[1];
def firstTouchFZ2 = inFZ2 and !inFZ2[1];

AddChartBubble(firstTouchFZ1, high, "FZ1", Color.YELLOW, yes);
AddChartBubble(firstTouchFZ2, high, "FZ2", Color.ORANGE, yes);

# ================================
# === TRAP DETECTION ============
# ================================
def aboveReclaim = close > reclaimLevel;
def belowReclaim = close < reclaimLevel;

def wasAbove = aboveReclaim[1];

def rejection = high > reclaimLevel and close < reclaimLevel;
def strongReject = close < open;

def trapShort = wasAbove and rejection and strongReject;

AddChartBubble(trapShort and !trapShort[1], high, "TRAP DN", Color.RED, yes);

# ================================
# === VWAP ======================
# ================================
plot VWAPLine = VWAP();
VWAPLine.SetDefaultColor(Color.CYAN);
VWAPLine.SetLineWeight(2);

def aboveVWAP = close > VWAPLine;
def belowVWAP = close < VWAPLine;

# ================================
# === ORB (TIME-BASED, FIXED) ====
# ================================

def newDay = GetYYYYMMDD() <> GetYYYYMMDD()[1];
def inORB = SecondsFromTime(orbStartTime) >= 0 and SecondsTillTime(orbEndTime) > 0;
def orbFinished = SecondsTillTime(orbEndTime) <= 0;

rec orbHigh =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbHigh[1]) then high
    else if inORB then Max(high, orbHigh[1])
    else orbHigh[1];

rec orbLow =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbLow[1]) then low
    else if inORB then Min(low, orbLow[1])
    else orbLow[1];

plot ORB_High_Line = if orbFinished then orbHigh else Double.NaN;
ORB_High_Line.SetDefaultColor(Color.GREEN);
ORB_High_Line.SetStyle(Curve.SHORT_DASH);
ORB_High_Line.SetLineWeight(2);

plot ORB_Low_Line = if orbFinished then orbLow else Double.NaN;
ORB_Low_Line.SetDefaultColor(Color.RED);
ORB_Low_Line.SetStyle(Curve.SHORT_DASH);
ORB_Low_Line.SetLineWeight(2);

def breakAboveORB = orbFinished and close > orbHigh;
def breakBelowORB = orbFinished and close < orbLow;

AddChartBubble(breakAboveORB and !breakAboveORB[1], low, "ORB UP", Color.GREEN, no);
AddChartBubble(breakBelowORB and !breakBelowORB[1], high, "ORB DN", Color.RED, yes);
# ================================
# === CONFIRMATION LOGIC ========
# ================================
def trendConfirmedShort = belowVWAP and breakBelowORB;
def trendConfirmedLong = aboveVWAP and breakAboveORB;

# ================================
# === SCORING ===================
# ================================
def avgVol = Average(volume, 20);
def highVol = volume > avgVol * 1.2;

def bull = close > open;
def bear = close < open;

def bullScore =
    (if highVol then 2 else 1) +
    (if bull then 2 else 0);

def bearScore =
    (if highVol then 2 else 1) +
    (if bear then 2 else 0);

def netScore = bullScore - bearScore;

# ================================
# === LABELS ====================
# ================================
AddLabel(yes,
    if gammaMode == 1 then "Gamma: SHORT (Trend Mode)"
    else "Gamma: LONG (Mean Reversion)",
    if gammaMode == 1 then Color.CYAN else Color.ORANGE
);

AddLabel(showLabel,
    "Score: " + netScore +
    if netScore >= 4 then " (LONG)"
    else if netScore <= -4 then " (SHORT)"
    else " (NO TRADE)",
    if netScore >= 2 then Color.GREEN
    else if netScore <= -2 then Color.RED
    else Color.GRAY
);

def noTrade = AbsValue(netScore) <= 2;

AddLabel(yes,
    if noTrade then "NO TRADE"
    else "ACTIVE",
    if noTrade then Color.GRAY else Color.WHITE
);

AddLabel(yes,
    if trendConfirmedShort then "CONFIRMED SHORT (ORB + VWAP)"
    else if trendConfirmedLong then "CONFIRMED LONG (ORB + VWAP)"
    else "NO CONFIRMATION",
    if trendConfirmedShort then Color.RED
    else if trendConfirmedLong then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    if netScore <= -4 then "Bias: SHORT (Sell Rips)"
    else if netScore >= 4 then "Bias: LONG (Buy Dips)"
    else "Bias: NEUTRAL",
    if netScore <= -4 then Color.RED
    else if netScore >= 4 then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    "Reclaim: " + reclaimLevel +
    " | FZ1: " + fadeZone1Low + "-" + fadeZone1High +
    " | FZ2: " + fadeZone2Low + "-" + fadeZone2High,
    Color.WHITE
);

# ================================
# === MARKET STATE LABEL =========
# ================================

# Distance from reclaim (extension proxy)
def extension = AbsValue(close - reclaimLevel);

# You can tweak this threshold
input extensionThreshold = 5.0;

def isExtended = extension > extensionThreshold;

# State conditions
def strongTrend = (trendConfirmedShort or trendConfirmedLong) and AbsValue(netScore) >= 4;
def weakEnv = AbsValue(netScore) <= 2 and !trendConfirmedShort and !trendConfirmedLong;
def lateTrend = isExtended and AbsValue(netScore) <= 2 and (trendConfirmedShort[10] or trendConfirmedLong[10]);

# Label logic
AddLabel(yes,
    if strongTrend then "TREND CONFIRMED (HIGH EDGE)"
    else if lateTrend then "LATE TREND / LOW TRADING EDGE"
    else if weakEnv then "CHOP / LOW CONVICTION"
    else "TRANSITION",
   
    if strongTrend then Color.GREEN
    else if lateTrend then Color.YELLOW
    else if weakEnv then Color.GRAY
    else Color.DARK_ORANGE
);

# ================================
# === ALERTS ====================
# ================================
Alert(trapShort, "Trap Detected → Short Setup", Alert.BAR, Sound.Bell);
Does the script update the Gamma levels automatically or do you have to input those levels manually based on barchart.com you mentioned above?
 
Is this just for SPY? How do you what "reclaim" level to use?
Reclaim and Fade Zones are hardcoded how can we make it dynamic for each day?
Great game plan writeup btw
Does the script update the Gamma levels automatically or do you have to input those levels manually based on barchart.com you mentioned above?

No — this script is NOT specific to the S&P 500
BUT…It is manually calibrated to a specific price level, so it behaves like it is tied to one product unless you adjust it. These are hardcoded price levels, So works perfectly on something trading near 640–650 is
  • Completely meaningless on:
    • $50 stock
    • $400 stock
    • $5000 index
It’s not an “indicator” in the usual sense. It’s a discretionary execution framework built around key price levels

Specifically:
  • Reclaim level → key pivot
  • Fade zones → supply/demand zones
  • VWAP + ORB → confirmation tools
  • Gamma mode → behavior assumption (trend vs mean reversion)
Key Insight (Very Important)- The script does ZERO automatic level discovery. It assumes you already know the important levels. So How Do You Pick the “Reclaim Level”? This is the real question and the edge. The reclaim level is usually:

1. Key intraday pivot
  • Prior day close
  • Overnight high/low
  • Pre-market high/low
2. High-volume node / liquidity level
  • Where price previously consolidated
  • Where large volume traded
3. Options-related level (most likely here)

Given the name “Gamma Edge” This is often:
  • Gamma flip level
  • Call wall / put wall
  • Dealer positioning pivot
4. VWAP reclaim (common usage)
  • Price below → bearish
  • Reclaim above → bullish shift
How to Think About It, Reclaim = “Who is in control?”

Price vs ReclaimMeaning
AboveBuyers in control
BelowSellers in control
RejectionTrap / reversal

How to Make It Universal (Better Version)

Right now: input reclaimLevel = 640; manual mode.

Better approach: (semi-automatic) Use:

def reclaimLevel = VWAP();

We are limited to the capabilities of TOS, maybe one day they can get it together.
 
If you wanted to just use like a single breaking point or reclaim like a call or put wall or gamma transistion zone you can use "dollar" amount of extensions instead of trying to find every point of gamma or GEX interest.
A couple of important notes:
  • Set pointValue correctly for the instrument:
    • ES = 50
    • MES = 5
    • NQ = 20
    • MNQ = 2
    • RTY = 50
    • M2K = 5
    • CL = 1000
    • GC = 100
    • Stocks/ETFs = 1
  • This version normalizes the extension logic and fade zone distance from reclaim in dollars, but reclaimLevel itself is still a manually chosen price level.
The cleanest next upgrade would be an auto-reclaim version using prior day midpoint, VWAP, or a custom pivot like I mentioned above.
Code:
# Gamma Edge Execution System
# Dollar-Normalized Version
# Rewritten from original framework - antwerks
# Normalized so extension / fade zones can be defined in dollars
# Works across futures, ETFs, and stocks by changing pointValue

declare upper;

# ================================
# === USER INPUTS ================
# ================================
input showLabel = yes;
input gammaMode = 1; # 1 = Short Gamma, -1 = Long Gamma

# Instrument normalization
input pointValue = 50.0; # ES=50, NQ=20, RTY=50, CL=1000, Stocks=1

# Core level
input reclaimLevel = 640.0;

# Fade zones in DOLLARS away from reclaim
input fadeZone1DollarLow  = 150.0;
input fadeZone1DollarHigh = 250.0;
input fadeZone2DollarLow  = 400.0;
input fadeZone2DollarHigh = 500.0;

# ORB
input orbStartTime = 0930;
input orbEndTime   = 1000;

# Extension logic in DOLLARS
input extensionThresholdDollars = 250.0;

# Volume scoring
input volLength = 20;
input highVolMultiplier = 1.2;

# ================================
# === DERIVED PRICE ZONES ========
# ================================
def fadeZone1Low  = reclaimLevel + (fadeZone1DollarLow  / pointValue);
def fadeZone1High = reclaimLevel + (fadeZone1DollarHigh / pointValue);
def fadeZone2Low  = reclaimLevel + (fadeZone2DollarLow  / pointValue);
def fadeZone2High = reclaimLevel + (fadeZone2DollarHigh / pointValue);

# ================================
# === YESTERDAY LEVELS ===========
# ================================
def yHigh = high(period = "DAY")[1];
def yLow  = low(period = "DAY")[1];

plot YH = yHigh;
YH.SetDefaultColor(Color.GREEN);
YH.SetStyle(Curve.SHORT_DASH);

plot YL = yLow;
YL.SetDefaultColor(Color.RED);
YL.SetStyle(Curve.SHORT_DASH);

# ================================
# === RECLAIM LEVEL ==============
# ================================
plot Reclaim = reclaimLevel;
Reclaim.SetDefaultColor(Color.WHITE);
Reclaim.SetLineWeight(2);
Reclaim.SetStyle(Curve.SHORT_DASH);

# ================================
# === GAMMA MODE COLORS ==========
# ================================
def isShortGamma = gammaMode == 1;

DefineGlobalColor("FZ1", if isShortGamma then Color.RED else Color.LIGHT_GRAY);
DefineGlobalColor("FZ2", if isShortGamma then Color.ORANGE else Color.GRAY);

# ================================
# === FADE ZONES ================
# ================================
plot FZ1L = fadeZone1Low;
plot FZ1H = fadeZone1High;
plot FZ2L = fadeZone2Low;
plot FZ2H = fadeZone2High;

FZ1L.SetDefaultColor(GlobalColor("FZ1"));
FZ1H.SetDefaultColor(GlobalColor("FZ1"));
FZ2L.SetDefaultColor(GlobalColor("FZ2"));
FZ2H.SetDefaultColor(GlobalColor("FZ2"));

AddCloud(FZ1L, FZ1H, GlobalColor("FZ1"), GlobalColor("FZ1"));
AddCloud(FZ2L, FZ2H, GlobalColor("FZ2"), GlobalColor("FZ2"));

# ================================
# === FIRST TOUCH DETECTION ======
# ================================
def inFZ1 = close >= fadeZone1Low and close <= fadeZone1High;
def inFZ2 = close >= fadeZone2Low and close <= fadeZone2High;

def firstTouchFZ1 = inFZ1 and !inFZ1[1];
def firstTouchFZ2 = inFZ2 and !inFZ2[1];

AddChartBubble(firstTouchFZ1, high, "FZ1", Color.YELLOW, yes);
AddChartBubble(firstTouchFZ2, high, "FZ2", Color.ORANGE, yes);

# ================================
# === TRAP DETECTION ============
# ================================
def aboveReclaim = close > reclaimLevel;
def belowReclaim = close < reclaimLevel;
def wasAbove = aboveReclaim[1];

def rejection = high > reclaimLevel and close < reclaimLevel;
def strongReject = close < open;

def trapShort = wasAbove and rejection and strongReject;

AddChartBubble(trapShort and !trapShort[1], high, "TRAP DN", Color.RED, yes);

# ================================
# === VWAP ======================
# ================================
plot VWAPLine = VWAP();
VWAPLine.SetDefaultColor(Color.CYAN);
VWAPLine.SetLineWeight(2);

def aboveVWAP = close > VWAPLine;
def belowVWAP = close < VWAPLine;

# ================================
# === ORB =======================
# ================================
def newDay = GetYYYYMMDD() <> GetYYYYMMDD()[1];
def inORB = SecondsFromTime(orbStartTime) >= 0 and SecondsTillTime(orbEndTime) > 0;
def orbFinished = SecondsTillTime(orbEndTime) <= 0;

rec orbHigh =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbHigh[1]) then high
    else if inORB then Max(high, orbHigh[1])
    else orbHigh[1];

rec orbLow =
    if newDay then Double.NaN
    else if inORB and IsNaN(orbLow[1]) then low
    else if inORB then Min(low, orbLow[1])
    else orbLow[1];

plot ORB_High_Line = if orbFinished then orbHigh else Double.NaN;
ORB_High_Line.SetDefaultColor(Color.GREEN);
ORB_High_Line.SetStyle(Curve.SHORT_DASH);
ORB_High_Line.SetLineWeight(2);

plot ORB_Low_Line = if orbFinished then orbLow else Double.NaN;
ORB_Low_Line.SetDefaultColor(Color.RED);
ORB_Low_Line.SetStyle(Curve.SHORT_DASH);
ORB_Low_Line.SetLineWeight(2);

def breakAboveORB = orbFinished and close > orbHigh;
def breakBelowORB = orbFinished and close < orbLow;

AddChartBubble(breakAboveORB and !breakAboveORB[1], low, "ORB UP", Color.GREEN, no);
AddChartBubble(breakBelowORB and !breakBelowORB[1], high, "ORB DN", Color.RED, yes);

# ================================
# === CONFIRMATION LOGIC =========
# ================================
def trendConfirmedShort = belowVWAP and breakBelowORB;
def trendConfirmedLong  = aboveVWAP and breakAboveORB;

# ================================
# === SCORING ====================
# ================================
def avgVol = Average(volume, volLength);
def highVol = volume > avgVol * highVolMultiplier;

def bull = close > open;
def bear = close < open;

def bullScore =
    (if highVol then 2 else 1) +
    (if bull then 2 else 0);

def bearScore =
    (if highVol then 2 else 1) +
    (if bear then 2 else 0);

def netScore = bullScore - bearScore;

# ================================
# === DOLLAR-NORMALIZED EXTENSION
# ================================
def extensionPoints = AbsValue(close - reclaimLevel);
def extensionDollars = extensionPoints * pointValue;
def isExtended = extensionDollars > extensionThresholdDollars;

# ================================
# === MARKET STATE LABEL =========
# ================================
def noTrade = AbsValue(netScore) <= 2;
def strongTrend = (trendConfirmedShort or trendConfirmedLong) and AbsValue(netScore) >= 4;
def weakEnv = AbsValue(netScore) <= 2 and !trendConfirmedShort and !trendConfirmedLong;
def lateTrend = isExtended and AbsValue(netScore) <= 2 and (trendConfirmedShort[10] or trendConfirmedLong[10]);

# ================================
# === LABELS =====================
# ================================
AddLabel(yes,
    if gammaMode == 1 then "Gamma: SHORT (Trend Mode)"
    else "Gamma: LONG (Mean Reversion)",
    if gammaMode == 1 then Color.CYAN else Color.ORANGE
);

AddLabel(showLabel,
    "Score: " + netScore +
    if netScore >= 4 then " (LONG)"
    else if netScore <= -4 then " (SHORT)"
    else " (NO TRADE)",
    if netScore >= 2 then Color.GREEN
    else if netScore <= -2 then Color.RED
    else Color.GRAY
);

AddLabel(yes,
    if noTrade then "NO TRADE"
    else "ACTIVE",
    if noTrade then Color.GRAY else Color.WHITE
);

AddLabel(yes,
    if trendConfirmedShort then "CONFIRMED SHORT (ORB + VWAP)"
    else if trendConfirmedLong then "CONFIRMED LONG (ORB + VWAP)"
    else "NO CONFIRMATION",
    if trendConfirmedShort then Color.RED
    else if trendConfirmedLong then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    if netScore <= -4 then "Bias: SHORT (Sell Rips)"
    else if netScore >= 4 then "Bias: LONG (Buy Dips)"
    else "Bias: NEUTRAL",
    if netScore <= -4 then Color.RED
    else if netScore >= 4 then Color.GREEN
    else Color.GRAY
);

AddLabel(yes,
    "Reclaim: " + Round(reclaimLevel, 2) +
    " | FZ1: $" + Round(fadeZone1DollarLow, 0) + "-$" + Round(fadeZone1DollarHigh, 0) +
    " | FZ2: $" + Round(fadeZone2DollarLow, 0) + "-$" + Round(fadeZone2DollarHigh, 0),
    Color.WHITE
);

AddLabel(yes,
    "Extension: $" + Round(extensionDollars, 0),
    if isExtended then Color.YELLOW else Color.GRAY
);

AddLabel(yes,
    if strongTrend then "TREND CONFIRMED (HIGH EDGE)"
    else if lateTrend then "LATE TREND / LOW TRADING EDGE"
    else if weakEnv then "CHOP / LOW CONVICTION"
    else "TRANSITION",
    if strongTrend then Color.GREEN
    else if lateTrend then Color.YELLOW
    else if weakEnv then Color.GRAY
    else Color.DARK_ORANGE
);

# ================================
# === ALERTS =====================
# ================================
Alert(trapShort, "Trap Detected -> Short Setup", Alert.BAR, Sound.Bell);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
961 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top