Creating volume subgraph from another instrument

Hi,

Since forex does not have "true volume," I want thinkorswim to plot forex futures volume in the volume subgraph for all major pairs. For example, the "EUR/USD" chart should plot the volume subgraph for "/6E" (the symbol for Euro FX futures). if I then switch to "AUD/USD," thinkorswim should automatically plot the volume subgraph for "6A."

I am using a study that breaks down volume for non-forex instruments, which colors volume bars to indicate the amount of buy/sell volume. I have modified the code so it looks like this:


Code:
#HINT: This study color codes volume by amount of volume on up-tick versus amount of volume on down-tick

declare lower;

def O = open;
def H = high;
def C = close;
def L = low;
def V;
if (GetSymbol() == "EUR/USD") {
    V = Volume("6E");
} else if (GetSymbol() == "USD/JPY") {
    V = Volume("6J");
} else if (GetSymbol() == "GBP/USD") {
    V = Volume("6B");
} else if (GetSymbol() == "USD/CAD") {
    V = Volume("6C");
} else if (GetSymbol() == "AUD/USD") {
    V = Volume("6A");
} else if (GetSymbol() == "MXN/USD") {
    V = Volume("6M");
} else if (GetSymbol() == "NZD/USD") {
    V = Volume("6N");
} else if (GetSymbol() == "EUR/GBP") {
    V = Volume("RP");
} else { #BASE CASE
    V = Volume;
}
def Buying = V*(C-L)/(H-L);
def Selling = V*(H-C)/(H-L);

# Selling Volume
Plot SV = selling;
SV.setPaintingStrategy(PaintingStrategy.Histogram);
SV.SetDefaultColor(Color.Red);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(5);

# Buying Volume
# Plot BV = Buying;
# Note that Selling + Buying Volume = Volume.
Plot BV =  V;
BV.setPaintingStrategy(PaintingStrategy.Histogram);
BV.SetDefaultColor(Color.Dark_Green);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);

I think there's an obvious mistake I'm making, but I can't put my finger on it. Can anyone point me in the right direction?

Thanks :)
 
Last edited:

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

Thanks! Can't believe I missed the forward slash when it came to writing the symbols of the futures. I even had it right in my original post.

When I change the price type of the chart settings for forex (from "Bid to "Last"), it appears to look choppy. Is there any way I can have the volume subgraph use "Last" when plotting volume data from forex futures, while the chart for the forex pair uses the "Bid" price type? Adding a price-type parameter in the volume functions (ex. from V = Volume("/6E"); to V = Volume("/6E", "Bid"); seems to remove the subgraph.
 
Last edited:

Thanks for all your help so far!

I'm looking at the thread linked and the thinkScript documentation side-by-side, and I'm not understanding why I wouldn't be able to plot the desired volume data (specifically using Last for price-type).

@cfire23 (OP in the linked post) is attempting to obtain the volume data (whether the specified price type is bid or ask) for the current symbol. @SleepyZ's answer makes sense: The documentation article on the volume function states that specifying ask, bid or mark as the price-type parameter "are only supported on intraday charts with time interval not greater than 15 days" for non-forex symbols. This is true even if PriceType constants "Bid" and "Ask" are used instead of passing along the priceType as a string value in the Volume function.

However, the documentation does not state any such restriction exists when "Last" is used as the price-type parameter (see linked documentation article for volume). Similarly. "PriceType.LAST" article does not specify any such restriction.

Please let me know if I am missing or misunderstanding something :)
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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