NexusFi: Find Your Edge


Home Menu

 





Flatten All Positions


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one ScottB with 2 posts (2 thanks)
    2. looks_two Big Mike with 1 posts (1 thanks)
    3. looks_3 lolu with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
      Best Posters
    1. looks_one ScottB with 1 thanks per post
    2. looks_two shodson with 1 thanks per post
    3. looks_3 NinjaTrader with 1 thanks per post
    4. looks_4 Merlin997 with 1 thanks per post
    1. trending_up 14,957 views
    2. thumb_up 7 thanks given
    3. group 8 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Flatten All Positions

  #1 (permalink)
 togier 
Boston, MA
 
Experience: Advanced
Platform: NinjaTrader
Broker: IB
Trading: EUR/USD
Posts: 42 since Apr 2010
Thanks Given: 1
Thanks Received: 3

Does anyone know the syntax for flatten all positions at a particular time? Can't find it in the help. Thanks.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090



togier View Post
Does anyone know the syntax for flatten all positions at a particular time? Can't find it in the help. Thanks.

There are two ways:

1) Close At Time is a strategy that will automatically close your position at a user defined time. A position will be closed using the NinjaTrader close algorithm. The user defined close time can be set via the "Time to flatten" property located in the [COLOR=#0066cc]Misc[/COLOR] tab. You can enable or disable this strategy via any NinjaTrader order entry screen's right mouse click context menu.

2) You build a strategy with the following commands:

if (ToTime(Time[0]) > Starttime)
{
ExitTypeofEntry(""
); 
}

Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709

This will close your positions at 4:00pm

 
Code
                            
if (ToTime(Time[0]) >= 160000)

{
   if (
Position.MarketPosition == MarketPosition.Long)
      
ExitLong();
   else if (
Position.MarketPosition == MarketPosition.Short)
      
ExitShort();


Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 wavey 
Germany / Italy
 
Experience: Advanced
Platform: NT8, TS, TV
Trading: Index Futures, FX
Posts: 83 since Nov 2009
Thanks Given: 51
Thanks Received: 37

while completely unsupported by the nt folks, you can try calling

 
Code
NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverything()
at your desired Time[x].

Beware though it's not limited to a specific symbol or account

Reply With Quote
Thanked by:
  #6 (permalink)
 
NinjaTrader's Avatar
 NinjaTrader  NinjaTrader is an official Site Sponsor
Site Sponsor

Web: NinjaTrader
AMA: Ask Me Anything
Webinars: NinjaTrader Webinars
Elite offer: Click here
 
Posts: 1,713 since May 2010
Thanks Given: 203
Thanks Received: 2,686


wavey View Post
while completely unsupported by the nt folks, you can try calling

 
Code
NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverything()
at your desired Time[x].

Beware though it's not limited to a specific symbol or account

Correct, this is not supported and it's internal implementation can change at any time. That being said, this method will do the following as of this post:

- Cycle through each open connection
- Cycle through each account within the connection
- Terminate any running strategies on the account
- Cancel any active orders on the account
- Close any open position on the account

Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
ScottB
Raleigh, NC
 
Posts: 3 since Jun 2010
Thanks Given: 0
Thanks Received: 2

In my experience FlattenEverything works great.

Reply With Quote
Thanked by:
  #8 (permalink)
 
Merlin997's Avatar
 Merlin997 
Prague
 
Experience: Advanced
Platform: NinjaTrader
Trading: 6E,TF, CL
Posts: 14 since May 2011
Thanks Given: 26
Thanks Received: 2


ScottB View Post
In my experience FlattenEverything works great.

Is possible to call
NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverything();
without strategy termination?

regards

Tomas

Reply With Quote
Thanked by:
  #9 (permalink)
ScottB
Raleigh, NC
 
Posts: 3 since Jun 2010
Thanks Given: 0
Thanks Received: 2

To the best of my knowledge, FlattenEverything() will stop the strategy. I only use it for error conditions.

Best Regards,
Scott

Reply With Quote
Thanked by:
  #10 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,610


 
Thread Moved


Moved to NinjaTrader Programming

(better late than never)



When creating a new thread, note which subforum you are in. Here is a short list of suggestions:

- Topic: Anything to do with an Elite indicator -> Subforum: The Elite Circle
- Topic: Looking for an existing indicator, or how-to use an indicator -> Subforum: (the platform)
- Topic: Programmer needing help with non-Elite indicator -> Subforum: (the platform) - Programming
- Topic: Want an indicator created/modified -> Reply to "Want indicator created free" in Elite Circle
- Topic: Vendors (trading rooms, commercial indicators) -> Subforum: Vendors/Product Reviews
- Topic: Discussion of Forex or Currency trading -> Subforum: Forex and Currency Trading
- Topic: Journals of your trading -> Subforum: Trading Journals or Elite Trading Journals
- Topic: General trading related discussions -> Subforum: Traders Hideout
- Topic: Discussion of a trading method -> Subforum: Traders Hideout
- Topic: Automated Trading -> Subforum: Elite Automated Trading

Last, any Elite Member may create more or less any of these topics in The Elite Circle at your own discretion (your support is appreciated).

This is just a short general list and doesn't cover everything. If you are unsure where to create your new thread, just create it in Traders Hideout and a moderator will move it if necessary.

-- Big Mike Trading


We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on October 13, 2012


© 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