Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm trying to develop a lunch-time lull range breakout strategy. In order to do that, I need to do some calculations based on referencing historical price bars by time.
I followed the suggestions posted on a related thread ... "How to reference historical price bars by time" ... but it was insufficient. The code works fine up until 1100 today. When it hits 1100 today, the code seems to calculate the difference between the price at 1300 yesterday and 1100 today (instead of yesterday). I want it to reference 1100 and 1300 from the previous day instead of the current day.
Here is my vision ...
1) Calculate the price difference between the following:
... a) Price at 1100 CST of the previous trading day (roughly the beginning of the lunch-time lull)
... b) Price at 1300 CST of the previous trading day (roughly the end of the lunch-time lull)
... c) For example: $25 price at 1300 yesterday - $20 price at 1100 yesterday = +$5 difference
2) If the price difference is positive:
... a) I would draw a trendline at the level of the price at 1130 (1130am CST today) + the price difference
... b) I would enter long if intrabar price crosses above the trendline ... I would exit at 2% profit or set a stop loss at 5%
... c) For example: $30 price at 1130 today + $5 difference = enter long if price crosses above $35 and set exit at either 2% profit or 5% stop loss
3) If the price difference is negative:
... a) I would draw a trendline at the level of the price at 1130 (1130am CST today) - the price difference
... b) I would enter short if intrabar price crosses below the trendline ... I would exit at 2% profit or set a stop loss at 5%
... c) For example: $30 price at 1130 today - $5 difference = enter short if price crosses below $25 and set exit at either 2% profit or 5% stop loss
Can you help answer these questions from other members on NexusFi?
the way you wrote the code TS has no way of knowing that you want to use the value at the same time of the last day. So you need to store the value yourself on the current day and use it on the next day.