NexusFi: Find Your Edge


Home Menu

 





Run code in nt7 at specific time each day


Discussion in NinjaTrader

Updated
    1. trending_up 1,633 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 2 attachments




 
Search this Thread

Run code in nt7 at specific time each day

  #1 (permalink)
pxp333
Parlin NJ/USA
 
Posts: 7 since Mar 2015
Thanks Given: 0
Thanks Received: 0

Hi All,

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?

Thanks in advance.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
11 thanks
GFIs1 1 DAX trade per day journal
11 thanks
  #2 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


pxp333 View Post
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[0] 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.

Cheers

Travel Well
Attached Files
Elite Membership required to download: RunDelayedCode.zip
Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
pxp333
Parlin NJ/USA
 
Posts: 7 since Mar 2015
Thanks Given: 0
Thanks Received: 0


Hi RatFink,

I really appreciate that you answered my query.

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

Best Regards & Good Trading!

Reply With Quote
  #4 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425

Hi @pxp333, Yes that's fine, I had assumed you only wanted M-F and would have session starts accordingly, glad to have helped, Cheers.

Travel Well
Visit my NexusFi Trade Journal Reply With Quote




Last Updated on May 24, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts