Ninjatrader simple code to exit all L and S positions at a particular time. - NinjaTrader | futures io social day trading
futures io futures trading


Ninjatrader simple code to exit all L and S positions at a particular time.
Updated: Views / Replies:4,070 / 2
Created: by birdoggg Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Ninjatrader simple code to exit all L and S positions at a particular time.

  #1 (permalink)
Elite Member
Charlotte, NC/USA
 
Futures Experience: Advanced
Platform: NT, TOS
Broker/Data: Mirus/ZF, AMP/CQG, TOS, MBT
Favorite Futures: Futures, Stocks, Bonds, Forex
 
Posts: 36 since May 2011
Thanks: 56 given, 9 received

Ninjatrader simple code to exit all L and S positions at a particular time.

Hey folks,

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


Last edited by birdoggg; October 13th, 2012 at 07:10 PM. Reason: clarify
Reply With Quote
 
  #2 (permalink)
Elite Member
NC, USA
 
Futures Experience: None
Platform: None Yet
Favorite Futures: Guitar
 
MrYou's Avatar
 
Posts: 403 since Jun 2011
Thanks: 618 given, 193 received

Answer
This post has been selected as an answer to the original posters question Answer

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.

 
Code
switch (Position.MarketPosition)
{
     case MarketPosition.Flat:
          if (...)
               EnterLong();
          else if (...)
               EnterShort();
          break;

     case MarketPosition.Long:
          if (ToTime(Time[0]) >= ToTime(15, 59, 0) && ToTime(Time[0]) <= ToTime(18, 59, 00))
               ExitLong();
          break;

     case MarketPosition.Short:
          if (ToTime(Time[0]) >= ToTime(15, 59, 0) && ToTime(Time[0]) <= ToTime(18, 59, 00))
               ExitShort();
          break;
}

Reply With Quote
The following user says Thank You to MrYou for this post:
 
  #3 (permalink)
Elite Member
Charlotte, NC/USA
 
Futures Experience: Advanced
Platform: NT, TOS
Broker/Data: Mirus/ZF, AMP/CQG, TOS, MBT
Favorite Futures: Futures, Stocks, Bonds, Forex
 
Posts: 36 since May 2011
Thanks: 56 given, 9 received


MrYou...

Thanks a lot! I will be checking this out (I want to have triple redundancy).


Reply With Quote

Reply



futures io > > > > Ninjatrader simple code to exit all L and S positions at a particular time.

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exit open positions based on time guppy EasyLanguage Programming 5 April 27th, 2017 02:53 PM
Multicharts code of scale in several positions Masse EasyLanguage Programming 2 August 25th, 2011 10:30 AM
a simple entry exit bar johni EasyLanguage Programming 7 July 23rd, 2011 05:34 AM
Coding a simple entry and exit johni EasyLanguage Programming 10 July 1st, 2011 07:44 AM
any ninjatrader programmers who can code simple strategies? mystiq NinjaTrader Programming 4 July 8th, 2010 10:45 AM


All times are GMT -4. The time now is 06:25 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-15 in 0.08 seconds with 25 queries on phoenix via your IP 107.20.115.174