ETF to Future Plot Conversion...problem w/ different Open Times


Active member
Hey All,

I've got a plot conversion tool that works very nicely on most futures charts because the futures instrument has the exact same market open time as its ETF counterpart. As you can see below, when I input 340 (QQQ value) into the indicator, I get a line plotted on the /NQ chart at 13949.46.

The problem is when I want to plot a line on /GC (who's market open time for me is 7:20am CST) from a determined line on GLD (who's open time for me is 8:30am CST). Because of the staggered opening times, the plot conversion won't work as it currently is written.

The code typically divides the 8:30 open price of the futures by the 8:30 open price of the ETF to get a factor. Then it multiplies the factor by the input value number to convert it for plotting that level on the futures chart.

Is there a way to modify this code so that it will take /GC's 8:30am open price instead of its RTH open price at 7:20? I've applied everything I know but still can't get it to work.

Thanks to anyone who chimes in!

Here's the code:
# ETF to Future Plot Conversion
# This indicator will plot a daily determined etf_value on its future
# counterpart's chart.

declare hide_on_daily;

input etf_value = 340.00;
input symbol = "QQQ";
input value_display = yes;
input showOnlyLastPeriod = yes;

def ChartSymbol = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then open else ChartSymbol[1];

def SymbolData = if open(symbol, AggregationPeriod.DAY, "Last") then open(symbol, AggregationPeriod.DAY, "Last") else SymbolData[1];

def factor = (ChartSymbol / SymbolData);

def StartTime = 0930;
def EndTime = 1600;

def startCounter = SecondsFromTime(StartTime);
def endCounter = SecondsTillTime(EndTime);
def RTetf_valueeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;

def RTetf_valuelot = if showOnlyLastPeriod then GetLastDay() <= GetDay() and GetLastYear() <= GetYear() else yes;

plot conversion;
conversion = if RTetf_valuelot and value_display and RTetf_valueeriod then factor * etf_value else Double.NaN;


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
315 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.