![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jan 2012
Posts: 26
Thanks: 4
Thanked 5 times in 4 posts
|
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]);
What is the best way to accomplish this? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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
Joydeep M.
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |