Is there a way to add SPY volume to SPX chart?

OliviaTOS

New member
I wonder if there is a way to add volume of SPY to the lower panel of SPX chart. The following study works if the main chart is a stock or etf such as AAPL or QQQ. However, it doesn't work if the main chart is SPX -- I guess it's because SPX doesn't have volume data and therefore the lower volume panel is by default missing? Any idea of how to make it work on the SPX chart? Much appreciated!

input ticker="SPY";​
declare lower;​
plot data = volume(ticker);​
data.setPaintingStrategy(PaintingStrategy.Histogram);​
data.SetDefaultColor(Color.Dark_Green);​
data.SetLineWeight(5);​
 
Solution
@OliviaTOS
You could just put your chart on an instrument like /ES and then use a study to hide the chart and plot the open, close, high, and low of SPX.
That would allow the lower chart to display your study for SPY volume.

YPoOLaB.png


Ruby:
input ticker = "SPX";
def SPXOpen = open(ticker);
def SPXClose = close(ticker) ;
def SPXLow = low(ticker);
def SPXHigh = high(ticker);

HidePricePlot(yes);
#Red Candlesticks -----------------------------------------------------------------|

def SPXOpen_fall = if SPXOpen > SPXClose
              then SPXOpen
              else Double.NaN;
def SPXHigh_fall   = if SPXOpen >= SPXClose
              then SPXHigh
              else Double.NaN;
def SPXLow_fall    = if SPXOpen >= SPXClose...
@OliviaTOS
You could just put your chart on an instrument like /ES and then use a study to hide the chart and plot the open, close, high, and low of SPX.
That would allow the lower chart to display your study for SPY volume.

YPoOLaB.png


Ruby:
input ticker = "SPX";
def SPXOpen = open(ticker);
def SPXClose = close(ticker) ;
def SPXLow = low(ticker);
def SPXHigh = high(ticker);

HidePricePlot(yes);
#Red Candlesticks -----------------------------------------------------------------|

def SPXOpen_fall = if SPXOpen > SPXClose
              then SPXOpen
              else Double.NaN;
def SPXHigh_fall   = if SPXOpen >= SPXClose
              then SPXHigh
              else Double.NaN;
def SPXLow_fall    = if SPXOpen >= SPXClose
              then SPXLow
              else Double.NaN;
def SPXClose_fall    = if SPXOpen >= SPXClose
              then SPXClose
              else Double.NaN;

AddChart(growColor = Color.DOWNTICK, fallColor = Color.UPTICK, neutralColor = Color.CURRENT, high = SPXHigh_fall, low = SPXLow_fall, open = SPXOpen_fall, close = SPXClose_fall , type = ChartType.CANDLE);


def SPXOpen_rise = if SPXOpen < SPXClose
                then SPXClose
                else Double.NaN;
def SPXHigh_rise  = if SPXOpen <= SPXClose
              then SPXHigh
              else Double.NaN;
def SPXLow_rise   = if SPXOpen <= SPXClose
              then SPXLow
              else Double.NaN;
def SPXClose_rise   = if SPXOpen <= SPXClose
              then SPXOpen
              else Double.NaN;

AddChart(growColor = Color.UPTICK, fallColor = Color.DOWNTICK, neutralColor = Color.CURRENT, high = SPXHigh_rise, low = SPXLow_rise, open = SPXOpen_rise, close = SPXClose_rise, type = ChartType.CANDLE);
 
Solution
Thanks so much, @Svanoy, for the nice trick! I tried and it works!

I just realized that a similar approach is to add a comparison study, and choose SPX as the secondary security and "candle" as the comparison style. But I like your approach better because drawings work on your phantom SPX chart, but not with the comparison study.

The only caveat is that the values on the chart (y axis, candle high/low/open/close, etc.) are for the hidden ticker (ES) but not for SPX. Showing the SPX values would help with option trading. I guess I can do the subtraction in my mind but wonder if there's an automatic fix. Lemme know if there is any suggestion.

Much appreciated!
 

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
373 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