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)
Guarantee this is a different type of multi time frame question.
I have a strategy relying on three time frames, e.g., hourly, 10 min, and 2 min charts on the same instrument.
The logic is similar, do some computation, then consult the parent and child for their 'view of the world'. Make trade decision, then move on.
since the logic is fairly complex, using the standard multi timeframe approach will make my hair grey. In addition, I'd like each to have its own position, so I came up with a new way of running the SAME strategy multiple instances, each with its own time frame.
The class will have some static members for cross strategy communication, so that each can read others' 'view of the world'.
So it's quite possible Hourly is going long while 10-min is going short and 2-min is going long. Of course I can further optimize it so that when 2-min is going short, then all upper layers will go short or revers if currently long, etc. etc. But that's not the point here.
Since we have hourly, or even day, weekly, I have to do my own tick count because per tick is too expensive, and OnBarClose is not an option. This is also fine.
The question then is, assuming the strategy will run every 20 ticks, and the 10-min one is responsible for trades and the other two are only acting as 'consultants'. How can I make sure the 10-min instance is invoked last, on each OnBarUpdate event handling?
A general question is, when multiple strategies are running on a NT system, is there a fixed sequence of how each event is handled? or They could be run in parallel or un-deterministic sequence. If it's the former, then how to set the sequence?
If it's random/or parallel then I have a serious problem since ideally I'd prefer the 10-min be run last so that whey it's asking others for information, it's up to date. You don't want the 10-min making trade decision based on 2-min's 20-tick ago data.
Of course if I want al three to run trades, then I have no choice but to leave to it per tick, then the problem is I have to worry about if the system can take the load.
Any suggestion as to solve or improve on this?
Thanks.
Can you help answer these questions from other members on NexusFi?
I think the only way to make sure they are called in the correct sequence would be to call them yourself. But with that approach you would be at the starting point where you could run one multi timeframe strategy. The other thing would be to instantiate the two "consultants" from within the strategy and then put the code there in a method that you call instead of in OnBarUpdate ( I never got this part right though) or you make the strategy instances available to each other and then call the methods you need (this is rather easy).
Thanks for the note.
Being relative new to NT programming, I didn't even know you can instantiate another strategies from within a strategy.
In this case, if I am 10-min, how do you specify the hour being the instance created?
And can we assume the hour instance will still have its DataSeries aligned with its own timeframe?
Well, that's the tricky part. I know it can be done but I am missing one piece, so I can't do it. But you can achieve the same with running a strategy that has a pointer to itself, that way you can call and access(depending on protection level of course) its methods and variables. So you have a strategy with the poiter, add and enable it in NT UI and then you can do whatever you want with it, like call a method every time the calling strategy has counted n number of ticks...