Accessing Yesterday's Close Price or Bar within an Intraday Strategy
Author: manonthemoon
Creation Date: 10/25/2010 2:41 PM
profile picture

manonthemoon

#1
Does anyone have a function to reference yesterday's last minute bar within a 1 minute scale? I want to compare the current bar's price to yesterday's close, to help identify gap up/down situations that still require intraday information. The below is an example of buying on a 5% gap down, but my code is not correct. Please help...

CODE:
Please log in to see this code.


I'd appreciate any help filling in the blanks.
profile picture

Eugene

#2
Here's an example:

Wiki > Knowledge Base > Mixing intraday and daily data -> Combining exits using yesterday's and today's prices

Also check out the WealthScript Programming Guide, Multi-Time Frame Analysis > Intraday/Daily.
profile picture

manonthemoon

#3
I did look at that before my original post, thanks, but I was not able to successfully devise a function based upon that code sample. Specifically, that example sets the scale to daily but never sets it back when doing the final comparison of the current minute bar to the daily bar. That confused me. And what would you pass into my YesterdaysClose function to establish the context needed before a "Bars daily = Bars" line of code? Sorry, I'm still confused on functionalizing this so that I can simply refer to a single yesterday's closing (or full day) bar in my Execute routine.
profile picture

Cone

#4
If you only to get yesterday's close, it's probably easier to do it without rescaling to Daily, and, it's very simple -

CODE:
Please log in to see this code.


profile picture

manonthemoon

#5
Thank you for that. Where is the Community Components documentation file that describes the Utility class and "FirstBarOfDay"? Specifically, I'm wondering what the "2" argument represents?

I'd still appreciate learning more about re-scaling if someone wouldn't mind helping show me how one would set up a function as I had tried to do above -- one that rescales and returns a bar representing the day before. As stated above, I never understood how to pass the current context to the function or if I needed to rescale back to intraday. Thanks.
profile picture

Eugene

#6
Click "Support", then "Knowledge Base", and there's a link to the Wealth-Lab Wiki. You'll find Community.Components documented there. Specifically, "Intraday Support Functions" is the target page.

With the pattern that Cone gave you (int closingBarYesterday), no need in a function or setting bar scale.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).