![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Posts: 124
Thanks: 0
Thanked 1 time in 1 post
|
Hi,
I want to be able to ensure that the proper quantity of my stop orders is matched with the entries that were filled at all times. For example, if I submit a 10 lot and it gets filled, I immediately place a 10 lot stop order. However if the entry order is partially filled, I then place the stop order with the partially filled quantity and amend it with every fill coming in in the OnExecution method. That seems to work just fine. What I want to do is write a method (lets call it CheckStops) that essentially goes through and 'matches' my entries with my placed stops - for quantity and to ensure that the stops are in fact placed (working or accepted). I call this method within OnBarUpdate with COBC=false. This is because my strategy is tick based and I want to ensure at all times that my entries have the properly placed stops for the entries. Under normal circumstances this is no problem. However once the stop gets partially filled, my STOP's quantity will be not equal to the entry's quantity (I guess I can check if the STOP is partially filled and then check the filled+quantity maybe) to determine if it adds up to it's entry. However the trickier portion of this is to check the OrderState of the STOP orders. Essentially I'll be checking for whether the STOP is working, accepted, partially filled or filled. The problem is that because of the asynchronous nature of getting fills (of the STOPs) and checking quantities, my per-tick check seems to be insufficient. In psuedocode this is what I'm doing in CheckStops(): //assume entryOrder and stopOrder are my C# Dictionaries //assume my entry orders are named entry1, entry2, etc //assume my stop orders are named entry1Stop, entry2Stop, etc foreach entryKey in entryOrder { foreach stopKey in stopOrder { if stopKey.startsWith(entryKey) { // stop Order has been found for the entry order // i want to make sure the quantity matches and the STOP is existent // UNDER ALL CIRCUMSTANCES } } } Does anyone have a "trick" or some code I can look at that does this? I'm using Unmanaged = true. thanks! |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 974 times in 957 posts
|
jonmoron, havw you considered checking the status in OnOrderUpdate()?
http://www.ninjatrader.com/support/h...rderupdate.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2009
Posts: 124
Thanks: 0
Thanked 1 time in 1 post
|
Bertrand,
Im not sure you understand the purpose behind this method. I want to check my stop order's presence at every tick and make sure the proper quantity is placed and working for my position. This is why I call CheckStops() in OnBarUpdate. I was looking for a nice algo that would satify my needs. thanks |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 974 times in 957 posts
|
Perhaps not, but what I understood is you looked for a way to access the different orderstates (partials) your stops would go through, this can be done in the OnOrderUpdate() for your strategy, as it would be called for each orderstate change.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Monitoring Strategy Orders/Fills | Richard Von | Strategy Development | 11 | 01-29-2010 12:48 PM |
| Placing orders for multiple instruments without monitoring data | palinuro | General Programming | 3 | 06-03-2008 07:32 AM |
| Strategy: Monitoring Stop-Loss and Profit Target Orders | NinjaTrader_Josh | Reference Samples | 0 | 02-23-2008 11:15 PM |
| Stop Loss Orders activated by number of trades past stop level | DoveforUsAll | Suggestions And Feedback | 1 | 02-08-2006 01:19 AM |
| Targets - Stop Orders or Stop Limit Orders? | Nereus | ATM Strategies (Discretionary Trading) | 3 | 05-31-2005 07:13 AM |