![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Miscellaneous Support Miscellaneous support issues. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Nov 2008
Posts: 87
Thanks: 0
Thanked 0 times in 0 posts
|
I have some code where I enter long 3 contracts with 3 seperate profit targets but the same stop loss.
If the first profit target is hit I would like to move the stop for the remaining two positions. I realise I can use the following syntax: SetStopLoss("LongEntry2",CalculationMode.Price,stoplossnew,true); SetStopLoss("LongEntry3",CalculationMode.Price,stoplossnew,true); assuming LongEntry1 is closed due to profit being hit. But how would I catch the event that the target is hit for LongEntry1? I can use code such as profit = GetCurrentBid() - LongOrder.AvgFillPrice; to calculate the current profit on an open position but wish to catch the event of a position hitting its target. Is this done using the OnPositionUpdate event? |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
mballagan,
You can check change in positions, then if you had your own variables tracking where the profit value and where the stop values are, you could then check it against price the moment a position change occurred and then you will be able to deduce which order was filled.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Nov 2008
Posts: 87
Thanks: 0
Thanked 0 times in 0 posts
|
Is a better way of doing it to use the OnExecution event? -
protectedoverridevoid OnExecution(IExecution execution) { if (LongOrder1 != null && LongOrder1.Token == execution.Order.Token) { if (execution.Order.OrderState == OrderState.Filled )) { //modify stop loss here for LongEntry2 & LongEntry3 using SetStopLoss } } |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
If you want to use advanced order methods, don't use Set() methods and just handle everything with IOrders.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trailing Stops | snaphook | ATM Strategies (Discretionary Trading) | 4 | 01-06-2009 04:03 PM |
| Trailing stops | newtrader1 | SuperDOM and other Order Entry Windows | 1 | 10-17-2008 06:36 AM |
| Trailing Stops | gdargento | ATM Strategies (Discretionary Trading) | 1 | 04-05-2007 10:56 AM |
| Trailing Stops | unclelou | ATM Strategies (Discretionary Trading) | 2 | 01-18-2005 03:46 PM |
| Trailing Stops | unclelou | Miscellaneous Support | 3 | 12-31-1969 06:00 PM |