AggregationPeriod.DAY lower timeframe issues

VIP_TOS

Member
Ruby:
def C = close(period = AggregationPeriod.DAY)[1];
AddLabel(1, c + " yesterday close", if c > 3 then color.green else color.red);



Can someone please help me understand why the code above shows a different close price on a 5min chart vs a daily chart? I am trying to get the correct previous day close price to show up on a 5m chart. It will only show correct on a loaded daily chart. I though the AggregationPeriod.DAY would do it on a 5m chart but I am getting a different close price on Futures.
 
Ruby:
input period_Type = AggregationPeriod.DAY;

def LastPrice = close;

input ticker1 = “/NQ”;
input NQ_PreviousDayClose = 13734.75;
def NQ_Percent_Chg = (lastPrice - NQ_PreviousDayClose )/ NQ_PreviousDayClose ;


addlabel(yes,"% Chg  " + asPercent(round(NQ_percent_Chg,4)),color.CYAN);



*update on my original post

I got the code above to work with input NQ_PreviousDayClose = (I would have to manually enter the CORRECT previous days close here)
I am trying to automatically get the CORRECT previous day close price for futures on a 5min chart. The code on the first original post above gets the correct close price on a day chart buy not a 5m chart. any help would be greatly appreciated.
 
@VIP_TOS
Previous day high, low, open, and close.
Ruby:
input sPeriod = {default DAY};
def offset = 1;

def varhigh = high(period = sPeriod)[offset];
def varlow = low(period = sPeriod)[offset];
def varopen = open(period = sPeriod)[offset];
def varclose = close(period = sPeriod)[offset];
 
FT.png

@Svanoy Thank you for the reply. But as you can see from the picture the correct CLOSE price does not match on the D chart vs 5min chart with that code for FUTURES. I have after hours enabled & Daily Close: Settlement on both within the settings. From my understanding & from what I was told from others is that the CLOSE Settlement on futures is determined by VWAP & this is the issue. It seems like allot of smart people tried to make this happen & there might not be a working solution. It just doesn't make since.. The TOS platform has the correct CLOSE on the D chart. I cant understand why a code can pull in the correct open, high, low but not the CLOSE.

appreciate the help & if you or anyone else have a working solution please share.



Ruby:
input sPeriod = {default DAY};
def offset = 1;

def H = high(period = sPeriod)[offset];
def L = low(period = sPeriod)[offset];
def O = open(period = sPeriod)[offset];
def C = close(period = sPeriod)[offset];

addlabel(1,"O  " + O);
addlabel(1,"H  " + H);
addlabel(1,"L  " + L);
addlabel(1,"C  " + C);
 

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