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)
Decoupling Strategy and Indicators: A new paradigm for Ninjatrader
The communication structure is there, you just have to use it. My strategy reports back all sorts of info, like trade status, if the strategy is running, or paused, what account is it running under, equity, etc. The most important thing to me is that the indicator periodically polls the strategy and asks it are you alive?, to which the strategy better answer yes I am! Nothing frustrates me more then seeing a great trade but am unable to get in because the strategy was not alive for some reason. As a scalper those few seconds trying to fgure out what's going on, will cost me a trade.
I have noticed at times the Ninja strategy (in the strategy tab) shows as active but it is not really....the OnBarUpdate appears not to be entered even though there is lots of price action. Is this what you are referring to?
Sometimes a strategy just stops responding, or is slow, or is in some startup mode, or I may have paused or stopped the strategy during the day and forgot to turn it back on, etc. The indicator periodically polls the strategy, and puts a status on the chart saying if the strategy is alive or not, so I know just by glancing at the chart that my strategy is running, paused or down.
I also use a feedback function that shows me running/paused. That’s the visual part.
I did two things to solve the problem:
Leaving OnBarUpdate empty. Instead I use OnMarketData (and OnOrderUpdate, OnExecution). This way the strategy is much busier (and faster) and always ready. It is not that much CPU consuming as only a very little part of the code is active when I have no order or position. Most of the code is only active when a command or execution is on the way.
I did outsource every variable that does make any sense for both indicator and strategy to the global section. This way they always have something to chat (and keep themselves awake and ready. This brings the two parts – in a conceptual sense - closer together.
Off-topic: I did outsource the globals to a separate indicator that is always running in the background. All the problems like what to start first or errors when using multiple strategies or the (unwanted) reset of variables by changing time-frame, instrument etc. are gone.