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)
Ninjatrader simple code to exit all L and S positions at a particular time.
RE: Ninjatrader Strategy time to exit all L and S positions (not using the NT system Flatten but code to put into the Strategy)...here is a snapshot..
In a Strategy I will like for it to exit any open positions in that Strategy only at a particular time during the day while keeping the Strategy running. I already have the time frames to actually take trades set, but just need it to exit all positions at a particular time and then let the next trade happen per the time frames I set. I already have used your thread on timefilters so thanks for that...however, it does not seem to address exiting all positions at x time.
I don't want to flatten all positions totally with other trades I may be in with other Strategies or manual trades within the Options>Data>Misc. Flatten all in NT...it should be in each Strategy that is deployed.
What I have it doing per the timefilters thread is:
Take any trades that may develop per the Strategy beginning on Sunday after 190000 (7pm est) to 115900 (midnight 11:59 pm est), then on Monday-Friday 000100 (one min passed midnight) til 153000 (3:30 pm est) and it then takes a break from taking trades til 190000 (7pm est) Monday-Friday and so on. So, there is a gap between 153000 (3:30 pm est) and 190000 (7 pm est) daily Mon-Friday that I do not want the strategy to actually taking any trades or in any trades either.
There is 29 +/- min (between 153000 3:30 pm est - 155900 4 pm est) where I tell it to stop actually entering any new trades after that time but it has 29 +/- extra min. for any establish trade positions to finish developing before it needs to exit all long and short positions for that particular Strategy until after 190000 (7 pm est) later that day.
Can you send me over some code that I can plug into the Strategy that tells it to exit all long and short positions (if any) for this Strategy at 155900 3:59 pm est?
and
Where would I put the code (beginning, middle, or end)? If you could take a basic simple strategy code and highlight the code you would have me put in to exit all positions in the Strategy at >= 155900 (3:59 pm est) and <= 185900 (6:59 pm est) that would be absolutely wonderful. I have some ideas, but can not get the code just right yet on exiting all long and short positions in the Strategy between those particular time frames.
P.S. By the way, I can not use the Flatten function in NT (Options>Data>Misc) because I need the Strategy to stay on at all times daily for the week without restarting it, don't want for it to Flatten any other separate Strategies I may have going, and lastly don't want it to Flatten any manual trades I may be in at the time (among other reasons). Therefore, that is why I need it to be put into each individual Strategy independent of NT).
Thanks everyone...
Greg
Can you help answer these questions from other members on NexusFi?
This switch(Position.MarketPosition) block is pretty much at the core of all my strategies. Also switch is faster than if statements, but its only useful for certain variables.