I have an automated strategy that works fine. The strategy requires that it's parameters be updated each day after the market close at 1715est. This calculation takes about 2 min to complete. Since I moved over to trading with ninja I have been running the calc each day at 1720est manually and then updating my strategy parameters before the market opens again at 1800est. I know that I can run this calc within onbarupdate but I would have to do it for every tick since ninja cannot know the last tick of the day until 1800est but then it's too late because I trade on the open at 1800est. But also because it takes about 2 min using onbarupdate it severely impacts the strategy's performance.
When I was trading with trade station I was able to use a simple timer event method outside of thier bar update method.
Where each day at 1720est my code would run even though the market was closed on thus my parameters got auto updated for me.
I still have the tradestaion code and maybe someone can translate it into ninja script?
I can supply it.
Can anyone show me how to trigger my calc at 1720est using nt7 outside of onbarupdate when the ES is closed M-F?
The attached code should do what you're looking for, I've just built it as an indicator, you can convert it to strategy or whatever you want. Change, modify or extend the code as needed, put your specific code in the 'myDelayedCodeHandler' routine. NB the Windows.Forms line addition in declarations.
The run code request is reset on every new session and then only run when not loading historical data. It tests fine under MR tonight, note that it only uses 'Now' and not an MR/Time time, you might want to do something different if you were backtesting or running under MR.
The run time is set in Properties, default is your 17:20, the timer runs free and checks every 5 secs, change it if needed, we could also only start it at the end of a session but that's just more code for not much gain. You could also just set the interval for a single shot amount instead, plenty of other ways too if the cat has a thicker skin.
Last edited by ratfink; May 23rd, 2015 at 07:01 PM.
I took some time and reviewed the code that you sent. There was probably a misunderstanding as to exactly what I needed. So your code was not able to run when the markets are closed such as today, Saturday. You can check this yourself by just setting the time to whenever before the markets reopen on Sunday, the code will not execute.
Anyhow what you showed me though was exactly what I was looking for because I was not that familiar with timer usage and the other special NT methods that you showed with your code.
I made an extensive rework of your code in both indicator and strategy forms. They have both been tested and you can test them yourself when the markets are closed. For instance set the time today, sat to say 22:00:00 and it will print out friday's last bar's high and your original message about place your code here. If you leave it running it will do it again each day at 22:00:00 in sync with your computer's clock.
Thanks again for helping me out this was an important part of my auto-trading that I just could not get my head around until now.
Attached are the exported NT7 Indicator and Strategy forms of this Timer Code for anyone that needs it. Just add it to your existing coding.DailyTimer.zip