Repaints MTF Gamma Scalping Indicator for ThinkorSwim

Repaints

Henk

New member
After listening to a comment by Don Kaufman of TheoTrade regarding the zero commission on stock/ETF trades with TDAmeritrade, I started learning about gamma scalping and found it very, very interesting.

The critical factor to keep in mind is the negative theta position of the straddles. This negative theta needs to be matched by gamma scalping, or even better more money needs to be made gamma scalping than the time decay to make a profit at the end of the trade.

From my limited research it seems that we need: (1) stocks price between $30-$50; (2) low IV% when starting; (3) good liquidity; (4) optionable stock/ETF.

It is not very difficult to build a scan in ToS for those 4 criteria. However, I would like to enhance the scan by searching for stocks that are now in a narrow trading range and are about to break-out of it. I have been thinking about (1) TTM Squeeze or (2) Fractal energy a.k.a. choppiness index, or ECI, expansion/contraction index. I am specially interested in the FE.

I am wondering whether y'all have any ideas or suggestions on gamma scalping. It seems a relatively save way to start learning how to daytrade. It is probably not very profitable, but that would not be a problem because I am a cautious trader.

Thanks to you all and I am eager to find out what you here think about gamma scalping.

Code:
#Hint: GAMMA SCALPER
input Length=20;
#hint Length: On intraday, this is the number of days used to calculate the atr. On interday, it is the number of chart aggregation periods used to calculate atr. \n\nrev:1.2.0 05/18/2017 comment-out labels except for the ATR label \nrev: 1.1.0 05/17/2017 plot standard deviation of true range offset from hod and lod. Post a chart label with the current SDTRange.


declare upper;

#add by cwen
declare once_per_bar;
### ATR + Visual


def ATRange = if getaggregationPeriod()<aggregationPeriod.DAY then
    MovingAverage(AverageType.WILDERS, TrueRange(high(period = AggregationPeriod.DAY), close(period = AggregationPeriod.DAY), low(period = AggregationPeriod.DAY)), Length)
    else ATR(length = Length);
def SDTRange=StDev(data = TrueRange(high(period = AggregationPeriod.DAY), close(period = AggregationPeriod.DAY), low(period = AggregationPeriod.DAY)),length=length);

plot high_std=
    if getaggregationPeriod()<aggregationPeriod.DAY then
        high(period = AggregationPeriod.DAY) - SDTRange
    else
        double.NAN;
high_std.setdefaultColor(color.GREEN);
high_std.setstyle(curve.MEDIUM_DASH);
high_std.setPaintingStrategy(paintingStrategy.DASHES);


plot low_std=
    if getaggregationPeriod()<aggregationPeriod.DAY then
        low(period = AggregationPeriod.DAY) + SDTRange
    else
        double.nan;
low_std.setDefaultColor(color.RED);
low_std.setStyle(curve.MEDIUM_DASH);
low_std.setPaintingStrategy(PaintingStrategy.DASHES);


plot High_ATR =
    if getaggregationPeriod()<aggregationPeriod.DAY then
        high(period = AggregationPeriod.DAY) - ATRange
    else
        highestAll(high-ATRAnge);
High_ATR.SetStyle(Curve.POINTS);
High_ATR.SetLineWeight(2);
High_ATR.SetDefaultColor(Color.GREEN);

plot Low_ATR =
    if getaggregationPeriod()<aggregationPeriod.DAY then
        low(period = AggregationPeriod.DAY) + ATRange
    else
        lowestAll(low+Atrange);

Low_ATR.SetStyle(Curve.POINTS);
Low_ATR.SetLineWeight(2);
Low_ATR.SetDefaultColor(Color.RED);

### Dates & Count

def Days = if BarNumber() >= 1
                then
                    if (high[1] - low[1]) > 0
                    then Days[1] + 1
                    else Days[1]
                else Days[1] ;

def ATR_Count = if BarNumber() >= 1
                then
                    if (high[1] - low[1]) > ATRange
                    then ATR_Count[1] + 1
                    else ATR_Count[1]
                else ATR_Count[1] ;

def ATR_Counter = if BarNumber() >= 1
                  then
                    if (high[1] - low[1]) < ATRange
                    then ATR_Counter[1] + 1
                    else ATR_Counter[1]
                else ATR_Counter[1];

### Labels

AddLabel(yes, "ATR: $" + Round(ATRange), Color.CYAN);
AddLabel(yes, "SDTR: $"+ round(SDTRange), color.CYAN);
#AddLabel(yes, "# of Bars Trading > ATR:: " + ATR_Count, Color.WHITE);
#AddLabel(yes, "# of Bars:: " + Days, Color.WHITE);
#AddLabel(yes, Round(ATR_Count / Days) / TickSize() + "% of Bars > ATR", Color.CYAN);
 
id say as long as you understand delta and the different meanings. personally not a big fan of using straddles do gamma scalping, but i do like strangles. keep in mind you should keep capital in spare in case you have to buy stock to balance gamma. rather starting with a straddle or strangle, why not start with a diag and adjust the short legs. ie start double diag. when price goes towards a short leg, clip the untested side and go naked. gamma scalping is a different style of trading that isnt really ideal for directional movement unless you shape spreads directional. from past experience gamma scalping works best in range bound trades. unless legging into a debit/expecting a directional move. thats a great pre-post earnings play
 
Orios, thanks for your kind reply. I would like to better understand your suggestion of using instead a double diagonal. When price goes towards a short leg I accumulate positive deltas on the put side or negative deltas on the call side. I do not understand what your mean with "clip the untested side and go naked." Do you mean to sell the long option on the untested side? What would I gain from that? Are you assuming that I would have profit from selling the untested side and then hope of a reversal on the tested side, so that the tested side becomes profitable?

How about buying 10 straddles of a range-bound stock/ETF that is about to break-out up or down and then sell the calls/put to go back to about zero delta? Again, my task would be to build a good scan for range-bound stocks/ETFs that are about to break out.

Alternatively, I could use e.g. Bollinger bands and set up a straddle when the price is at the middle of the band and then sell options when the price reaches the lower or upper band. I would need to scan for stocks that oscillate between the upper and lower bands, as well as having bands with a decent price difference. In addition the swings should not be to far apart.

Thanks.
 
Recently, saw this indicator on the forum https://usethinkscript.com/threads/gamma-scalping-indicator-for-thinkorswim.1642
I am not sure why it won't plot in premarket. I tried to modify it but the result is different. I am not sure what was wrong in this code, can someone help me on making this script plot during premarket?
Thank you!

Code:
#Hint: GAMMA SCALPER
input Length=20;
#hint Length: On intraday, this is the number of days used to calculate the atr. On interday, it is the number of chart aggregation periods used to calculate atr. \n\nrev:1.2.0 05/18/2017 comment-out labels except for the ATR label \nrev: 1.1.0 05/17/2017 plot standard deviation of true range offset from hod and lod. Post a chart label with the current SDTRange.


declare upper;

#add by cwen
declare once_per_bar;
### ATR + Visual


def ATRange = if getaggregationPeriod()<aggregationPeriod.DAY then
    MovingAverage(AverageType.WILDERS, TrueRange(high(period = AggregationPeriod.DAY), close(period = AggregationPeriod.DAY), low(period = AggregationPeriod.DAY)), Length)
    else ATR(length = Length);
def SDTRange=StDev(data = TrueRange(high(period = AggregationPeriod.DAY), close(period = AggregationPeriod.DAY), low(period = AggregationPeriod.DAY)),length=length);

plot high_std=
    if getaggregationPeriod()<aggregationPeriod.DAY then
        high(period = AggregationPeriod.DAY) - SDTRange
    else
        double.NAN;
high_std.setdefaultColor(color.GREEN);
high_std.setstyle(curve.MEDIUM_DASH);
high_std.setPaintingStrategy(paintingStrategy.DASHES);


plot low_std=
    if getaggregationPeriod()<aggregationPeriod.DAY then
        low(period = AggregationPeriod.DAY) + SDTRange
    else
        double.nan;
low_std.setDefaultColor(color.RED);
low_std.setStyle(curve.MEDIUM_DASH);
low_std.setPaintingStrategy(PaintingStrategy.DASHES);


plot High_ATR =
    if getaggregationPeriod()<aggregationPeriod.DAY then
        high(period = AggregationPeriod.DAY) - ATRange
    else
        highestAll(high-ATRAnge);
High_ATR.SetStyle(Curve.POINTS);
High_ATR.SetLineWeight(2);
High_ATR.SetDefaultColor(Color.GREEN);

plot Low_ATR =
    if getaggregationPeriod()<aggregationPeriod.DAY then
        low(period = AggregationPeriod.DAY) + ATRange
    else
        lowestAll(low+Atrange);

Low_ATR.SetStyle(Curve.POINTS);
Low_ATR.SetLineWeight(2);
Low_ATR.SetDefaultColor(Color.RED);

### Dates & Count

def Days = if BarNumber() >= 1
                then
                    if (high[1] - low[1]) > 0
                    then Days[1] + 1
                    else Days[1]
                else Days[1] ;

def ATR_Count = if BarNumber() >= 1
                then
                    if (high[1] - low[1]) > ATRange
                    then ATR_Count[1] + 1
                    else ATR_Count[1]
                else ATR_Count[1] ;

def ATR_Counter = if BarNumber() >= 1
                  then
                    if (high[1] - low[1]) < ATRange
                    then ATR_Counter[1] + 1
                    else ATR_Counter[1]
                else ATR_Counter[1];

### Labels

AddLabel(yes, "ATR: $" + Round(ATRange), Color.CYAN);
AddLabel(yes, "SDTR: $"+ round(SDTRange), color.CYAN);
#AddLabel(yes, "# of Bars Trading > ATR:: " + ATR_Count, Color.WHITE);
#AddLabel(yes, "# of Bars:: " + Days, Color.WHITE);
#AddLabel(yes, Round(ATR_Count / Days) / TickSize() + "% of Bars > ATR", Color.CYAN);
 
True Gamma Scalping is more about Static/Dynamic Delta Hedging. It's ALL about Deltas and how fast you get there and GEX (gamma exposure).

There is little reason to use ATR in these calculations. It has almost nothing to do with where hedging is applied due to it's lookback, as hedging is look forward.

It's more of a Daily P&L driven model which is about Theta capture over time, and being "directionally neutral" far out from Expiry, hence Straddles and Strangles, and managing gamma exposure nearing expiry each week. They re-balance at open and the last hour near close. That's why most middle of the day are slow and boring. Measuring the Stddev of the ranges of gamma is far more accurate. that and Sine wave / RSI measurements are about all you need as far as indicators. The FE stuff, meh, too complex for TOS imo.

Being neutral lets the MMs develop scalp zones strictly from market structure, using Gamma P&L and measuring Volatility (realized or historic vs. predicted and expected) every 5-30 minutes depending on need. This is almost a pure reversion-to-the-mean strategy, and they know with about 93.5% accuracy when they're going to be right, their algos react fast.

Learn to watch for their moves (straddles or strangles). SpotGamma has an options flow course on this, even built an indicator (HIRO) but we found it better as a scanner than real-time alert system. Yet, the concept is solid.
 
Last edited:
Does this ATR/SD based levels indicator repaint?

Is it possible to make this non-repaint? Or is that possible it general? Thanks
Yes, this script repaints.

No it is not possible to make this script not repaint.

MTF scripts repaint because they are set to a higher timeframe.
This script looks at the daily timeframe. As there is no way to determine what the final bar in the day will be; the script will repaint the entire day until the market closes.
 

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

Thread starter Similar threads Forum Replies Date
I MTF Average Daily Close Line Questions 2
D MTF Stoch Signals Questions 0
B MTF Previous Week Open / Close Questions 1
P MTF Stacked Averages? Questions 0
S MTF Shaded EMA Questions 4

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
435 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