Start Futures Chart new each day at 0930 ET

timetraveler

New member
VIP
Hello friends. I am stumped. I've gotten pretty far but can't designate my chart to start fresh at 0930 ET.

I'm doing a point comparison between two futures symbols.

Im trying to take the value of the first future at Market Open (0930) and subtracting it's current value whatever it might be at anytime throughout the day.

Doing the same for the second symbol. And then getting a final difference between the two.


symbol 1 ( Open - Current Value)

- (minus)

symbol 2 (Open - Current Value)

The issue I'm having is that the Open Value always reverts to 1800 ET when futures reopen. I'd like to plot the value of the 0930 market open instead.

Note: Both symbols need to be entered in the chart: /MNQ-/MES

Any help is Greatly appreciated. Code Attached.

Thank you.






declare lower;

plot zerobase = 0;

input start = 0930;
input ShowTodayOnly = {default "No", "Yes"};
input showOnlyLastPeriod = yes;
input aggregationPeriod = AggregationPeriod.DAY;


def time = SecondsTillTime(start);

def o1 = open(GetSymbolPart(1), aggregationPeriod);
def c1 = close(GetSymbolPart(1));
def o2 = open(GetSymbolPart(2), aggregationPeriod);
def c2 = close(GetSymbolPart(2));


def s1_open = if time and aggregationPeriod then o1 else s1_open[1];
def s2_open = if time and aggregationPeriod then o2 else s2_open[1];

def s1_value = if time and aggregationPeriod then (c1 - s1_open) else (c1 - s1_open) ;
def s2_value = if time and aggregationPeriod then (c2 - s2_open) else (c2 - s2_open) ;

plot s1value = (s1_value);
s1value.SetDefaultColor(CreateColor (200, 200, 200));

plot s2value = (s2_value);
s2value.SetDefaultColor(CreateColor (255, 0, 255));

AddVerticalLine(SecondsTillTime(1800) == 0, "Futures OPEN", Color.WHITE, Curve.SHORT_DASH);

AddVerticalLine(SecondsTillTime(0930) == 0, "Market OPEN", Color.WHITE, Curve.SHORT_DASH);
 
Last edited:
Solution
YES! I modified your code slightly since I'm using (GetSymbolPart()) rather the inputs.

Here is the modification if you're interested:

Thank you!!


input start_time = 0930;

def Start = if secondsFromTime(start_time) >= 0 and secondsFromTime(start_time)[1] < 0 then 1 else 0;

def symbol_1_open = if Start == 1 then open(GetSymbolPart(1)) else symbol_1_open[1];
def symbol_2_open = if Start == 1 then open(GetSymbolPart(2)) else symbol_2_open[1];

def symbol_1_delta = close(GetSymbolPart(1)) - symbol_1_open;
def symbol_2_delta = close(GetSymbolPart(2)) - symbol_2_open;


plot symbol1_d = symbol_1_delta;
plot symbol2_d = symbol_2_delta;

plot indicator = symbol_1_delta - symbol_2_delta;
AddVerticalLine(start == 1, text = "Market Open");
Is this what you've described:
Code:
declare lower;

input symbol1 = "/MNQ";
input symbol2 = "/MES";

input start_time = 0930;

def Start = if secondsFromTime(start_time) >= 0 and secondsFromTime(start_time)[1] < 0 then 1 else 0;

def symbol_1_open = if Start == 1 then open(symbol = symbol1) else symbol_1_open[1];
def symbol_2_open = if Start == 1 then open(symbol = symbol2) else symbol_2_open[1];

def symbol_1_delta = close(symbol = symbol1) - symbol_1_open;
def symbol_2_delta = close(symbol = symbol2) - symbol_2_open;

plot indicator = symbol_1_delta - symbol_2_delta;
AddVerticalLine(start == 1, text = "Reset");

Not sure...

-mashume
 
Last edited:

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

YES! I modified your code slightly since I'm using (GetSymbolPart()) rather the inputs.

Here is the modification if you're interested:

Thank you!!


input start_time = 0930;

def Start = if secondsFromTime(start_time) >= 0 and secondsFromTime(start_time)[1] < 0 then 1 else 0;

def symbol_1_open = if Start == 1 then open(GetSymbolPart(1)) else symbol_1_open[1];
def symbol_2_open = if Start == 1 then open(GetSymbolPart(2)) else symbol_2_open[1];

def symbol_1_delta = close(GetSymbolPart(1)) - symbol_1_open;
def symbol_2_delta = close(GetSymbolPart(2)) - symbol_2_open;


plot symbol1_d = symbol_1_delta;
plot symbol2_d = symbol_2_delta;

plot indicator = symbol_1_delta - symbol_2_delta;
AddVerticalLine(start == 1, text = "Market Open");
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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