NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-23-2012, 06:17 AM   #1
dpicon
Junior Member
 
Join Date: Jan 2012
Posts: 26
Thanks: 4
Thanked 5 times in 4 posts
Default Recommended way to reverse a position.

Hi,

I have an strategy running multiple "substrategies". One one strategy opens an opposite position to the current position I would like to close the open position and then enter in the new direction.

i.e.- MarketPosition is long, and we get a short signal, so we close the long and then open a long.

I've tried doing:
Code:
 
if (Position.MarketPosition == MarketPosition.Long)
{
      Position.Close();
}
EnterShort(contratos, EntryName[StrategyOne]);
But although in replay and backtesting works OK in live tests sometimes I end up having positions unclosed.


What is the best way to accomplish this?
dpicon is offline  
Reply With Quote
Old 05-23-2012, 06:45 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello dpicon,
Unfortunately, Position.Close is beyond what we could supported.

The standard EnterLong EnterShort should reverse your position.

Position.MarketPosition returns the overall strategy position. You can have better control if you assign the IOrder objects for each individual orders.
http://www.ninjatrader.com/support/h...tml?iorder.htm

Also please make sure to use the TraceOrder code. It will let know which order is being submitted.
http://www.ninjatrader.com/support/h...raceorders.htm
NinjaTrader_Joydeep is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reverse Position atxim ATM Strategies (Discretionary Trading) 1 09-23-2011 08:38 AM
Reverse Position IISSG Strategy Development 3 10-22-2009 06:51 AM
Reverse Position TxenNT General Programming 4 10-08-2009 09:48 AM
Reverse a position with 1 order Joerg Automated Trading 5 01-16-2009 09:50 AM
Best way to reverse a position? Idruna Strategy Development 10 09-24-2008 10:17 PM


All times are GMT -6. The time now is 06:24 PM.