RickK
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:
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:
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;
#COLLECTS OPEN PRICE FOR FUTURE OR EQUITY
def ChartSymbol = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then open else ChartSymbol[1];
#COLLECTS OPEN PRICE FOR ETF
def SymbolData = if open(symbol, AggregationPeriod.DAY, "Last") then open(symbol, AggregationPeriod.DAY, "Last") else SymbolData[1];
#CONVERSION FACTOR CALCULATION
def factor = (ChartSymbol / SymbolData);
#START/END TIME
def StartTime = 0930;
def EndTime = 1600;
#COUNTER
def startCounter = SecondsFromTime(StartTime);
def endCounter = SecondsTillTime(EndTime);
def RTetf_valueeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
#SESSION
def RTetf_valuelot = if showOnlyLastPeriod then GetLastDay() <= GetDay() and GetLastYear() <= GetYear() else yes;
#PLOT
plot conversion;
conversion = if RTetf_valuelot and value_display and RTetf_valueeriod then factor * etf_value else Double.NaN;
conversion.SetDefaultColor(color.blue);
conversion.SetLineWeight(5);
#####End