Options Gamma script does not work on my platform

3AMBH

Active member
2019 Donor
Script is for Options chain under Trade Tab to show highlighted Gamma

Hi, Please see post https://usethinkscript.com/threads/options-gamma-study.11951/page-5#posts in order to see history. The following script works for a member by the name of Focus. The same script does not work for me. He has sent this also and it does not work for me either https://tos.mx/VWf2UpO (This link shows up in my Watchlists selections)

Here is the script he posted: Can someone please tell me ahy it des not work for me and does work for Focus? Thanks

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();

def rangeHigh = Highestall (absvalue(data)) ;


assignbackgroundcolor (if absvalue(data) > 1000000 then color.white else if AbsValue(data) > 500000 then color.gray else if absvalue(data) > 200000 then color.green else if absvalue(data) > 100000 then color.yellow else if AbsValue(data) > 50000 then color.light_orange else if AbsValue(data) > 20000 then color.cyan else if AbsValue(data) > 9999 then createcolor(250,150,100) else color.black);
 
Last edited:
Script is for Options chain under Trade Tab to show highlighted Gamma

Hi, Please see post https://usethinkscript.com/threads/options-gamma-study.11951/page-5#posts in order to see history. The following script works for a member by the name of Focus. The same script does not work for me. He has sent this also and it does not work for me either https://tos.mx/VWf2UpO (This link shows up in my Watchlists selections)

Here is the script he posted: Can someone please tell me ahy it des not work for me and does work for Focus? Thanks

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();

def rangeHigh = Highestall (absvalue(data)) ;


assignbackgroundcolor (if absvalue(data) > 1000000 then color.white else if AbsValue(data) > 500000 then color.gray else if absvalue(data) > 200000 then color.green else if absvalue(data) > 100000 then color.yellow else if AbsValue(data) > 50000 then color.light_orange else if AbsValue(data) > 20000 then color.cyan else if AbsValue(data) > 9999 then createcolor(250,150,100) else color.black);
@Chemmy @BenTen can you help?
 
Just off the top of my head; check the spread, check the column's aggregation, and make sure you're using one of the original default column scripts. Don't use the share-link script directly, copy and paste that code into an original slot.
 
Script is for Options chain under Trade Tab to show highlighted Gamma

Hi, Please see post https://usethinkscript.com/threads/options-gamma-study.11951/page-5#posts in order to see history. The following script works for a member by the name of Focus. The same script does not work for me. He has sent this also and it does not work for me either https://tos.mx/VWf2UpO (This link shows up in my Watchlists selections)

Here is the script he posted: Can someone please tell me ahy it des not work for me and does work for Focus? Thanks

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();

def rangeHigh = Highestall (absvalue(data)) ;


assignbackgroundcolor (if absvalue(data) > 1000000 then color.white else if AbsValue(data) > 500000 then color.gray else if absvalue(data) > 200000 then color.green else if absvalue(data) > 100000 then color.yellow else if AbsValue(data) > 50000 then color.light_orange else if AbsValue(data) > 20000 then color.cyan else if AbsValue(data) > 9999 then createcolor(250,150,100) else color.black);

if you want help, please say more than 'doesn't work'

what did you try.
what did you see.
 
I copy and paste that code into an original slot and this is what shows: ( get this both with the script and the link)


S1Rlqy4.png
 
Try each of these lines individually by themselves, with no other code:
  1. plot data = isPut();
  2. plot data = Gamma();
  3. plot data = Open_Interest();
Tell us the values for each individually.
 
While we're at it, @3AMBH, on the column, try setting the aggregation to intraday, enable extended hours, and then set it back to daily.

Most people don't realize how the extended hours setting can have an effect on daily charts, and that the setting is remembered when switching from intraday back to daily. I was able to reproduce the problem this way, and then fix it. Assuming its the same problem, and not a different one.

If that doesn't work, tell me the values of the plots I listed a few posts up.
 
@Focus I thought it was working fine for you, but not for @3AMBH ?

What I meant was, @3AMBH should do that in the column, not a chart.

If I am incorrect, please inform.
I am putting the code into customise in the options chain.

I have this code as a choice for Gamma and it works just fine.
plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();
assignbackgroundcolor(if AbsValue(data) > 2000 then color.orange else color.black);
data.assignvaluecolor(if AbsValue(data) > 2000 then color.black else color.current);

It's the code Focus uses that does not work for me. THis does not work for me

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();

def rangeHigh = Highestall (absvalue(data)) ;


assignbackgroundcolor (if absvalue(data) > 1000000 then color.white else if AbsValue(data) > 500000 then color.gray else if absvalue(data) > 200000 then color.green else if absvalue(data) > 100000 then color.yellow else if AbsValue(data) > 50000 then color.light_orange else if AbsValue(data) > 20000 then color.cyan else if AbsValue(data) > 9999 then createcolor(250,150,100) else color.black);
 
The code is not the problem, its just some basic arithmetic and some built-in functions. The syntax is correct. The issue is at the platform / settings level, outside of the code, and may involve some of the platform's lesser known "dirty tricks," for lack of a better word.

Here is the code both working and not working, even though everything appears to be identical on the surface.

wDEB7Af.png

rKyqVwI.png


Most of this has already been mentioned here to elsewhere, but I am just going to summarize to get everything in one place.

For one, get rid of the rangeHigh line, its not doing anything.

The option chain's spread must be set to Single.

OHh8I7C.png


Please ensure that the problem code is inserted into an original column script slots that comes with TOS by default. Custom columns are finicky when used on the option chain, especially if they are extra custom columns obtained via share link, as opposed to the original set.

Secondly, and I know this sounds weird, but set the column to the Daily aggregation, and with Extended Hours On. To do this, you must select any random intraday aggregation, which will display the extended hours check box, turn extended hours on, and then set it back to daily.

If that doesn't solve the issue, here is what I need:

You mentioned that one script works, while the other one doesn't. Do you have them both saved as two separate custom column scripts? Or, are you just moving each code back and forth into the same box with Copy & Paste perhaps? If you do have two separate scripts, what happens if you switch each of their codes from one to the other?

Lastly, if all else fails, on column that doesn't work, I need you to set all that code aside, by either commenting it out with #, or copy and pasting it into a text file for safe keeping. Then, in that same code exact box, do each of these, one at a time, by themselves, and tell me the result of each:
  1. plot data = isPut();
  2. plot data = Gamma();
  3. plot data = Open_Interest();
They will fail at different times for different reasons, and if one fails the whole thing fails, I need to know the root of the problem.
 
Hey Joshua,
I got rid of the rangeHigh line, set to daily and made sure Spread was set to single. ALL my attempts to have the code work have been on SPX. AS you can see My Gamma original code works on both SPX and SPY. I trade SPX most of the time. Thank you for all you work on this Joshua!!! No need to spend any more time on it.

It functions in SPY but it does not function in SPX.


OhIFhTE.png


7gQms18.png


Apparently, the rangeHigh line is was what caused the NaN, not sure

Take care
 
It functions in SPY but it does not function in SPX.

The values on SPX are smaller, it works from a functional standpoint, its just not meeting the criteria often. The min value for a color is 9999, whereas the values for SPX might only be around 500 to 2500. Its being set to black deliberately.

COYN11F.png


Try playing around with this, it raises the values x10 relative to the color scale, specifically for SPX.
You can change the 10 to what ever you want.

plot data = (if GetunderlyingSymbol() == "SPX" then 10 else 1) *
(if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest());

Assignbackgroundcolor (if absvalue(data) > 1000000 then color.white else if AbsValue(data) > 500000 then color.gray else if absvalue(data) > 200000 then color.green else if absvalue(data) > 100000 then color.yellow else if AbsValue(data) > 50000 then color.light_orange else if AbsValue(data) > 20000 then color.cyan else if AbsValue(data) > 9999 then createcolor(250,150,100) else color.current);
 
The values on SPX are smaller, it works from a functional standpoint, its just not meeting the criteria often. The min value for a color is 9999, whereas the values for SPX might only be around 500 to 2500. Its being set to black deliberately.

COYN11F.png


Try playing around with this, it raises the values x10 relative to the color scale, specifically for SPX.
You can change the 10 to what ever you want.

plot data = (if GetunderlyingSymbol() == "SPX" then 10 else 1) *
(if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest());

Assignbackgroundcolor (if absvalue(data) > 1000000 then color.white else if AbsValue(data) > 500000 then color.gray else if absvalue(data) > 200000 then color.green else if absvalue(data) > 100000 then color.yellow else if AbsValue(data) > 50000 then color.light_orange else if AbsValue(data) > 20000 then color.cyan else if AbsValue(data) > 9999 then createcolor(250,150,100) else color.current);
I very much appreciate your insights and help with this. Will Try tomorrow. Thanks
 
Hey Joshua,
I got rid of the rangeHigh line, set to daily and made sure Spread was set to single. ALL my attempts to have the code work have been on SPX. AS you can see My Gamma original code works on both SPX and SPY. I trade SPX most of the time. Thank you for all you work on this Joshua!!! No need to spend any more time on it.

It functions in SPY but it does not function in SPX.


OhIFhTE.png


7gQms18.png


Apparently, the rangeHigh line is was what caused the NaN, not sure

Take care

How is the GEX going?
 
Hey Joshua,
I got rid of the rangeHigh line, set to daily and made sure Spread was set to single. ALL my attempts to have the code work have been on SPX. AS you can see My Gamma original code works on both SPX and SPY. I trade SPX most of the time. Thank you for all you work on this Joshua!!! No need to spend any more time on it.

It functions in SPY but it does not function in SPX.


OhIFhTE.png


7gQms18.png


Apparently, the rangeHigh line is was what caused the NaN, not sure

Take care
How is the indicator working for you?
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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