Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
1 ATM order at a time, please
Collapse
X
-
Uh-oh. My plan is to cancel the order should it not fill and then run 4 ticks away. Is that going to be an issue? Also, is there a formal code snippet I should be using for that?
EDIT: Moved entry code to but still doesn't work. Please see attached.
Thanks.Attached FilesLast edited by dsraider; 02-03-2010, 04:20 PM.
Comment
-
Dave, unfortunately no snippet available for this - you just need to compare to your attempting limit order price and then cancel order them if your threshhold is breached.
What is the TraceOrders output telling you on the latest change? Are orders placed, or not all? Any errors in the log?
You may want to comment out most portions of the code and then slowly build from the ground up testing each step if the outcome is what you would expect...for example only work with one position first and don't scale in and use just static target and stop, once this works, you can safely move on to the next complexity level.
Comment
-
Orders aren't being entered at all so the Log and the Output window had nothing. Now that you fixed that "1a" bug for me (thanks again), I changed it back to a market order and everything works perfectly (including trails). That's what leads me to believe my limit order language may be wrong, but I just can't figure it out.
UPDATE: for limit orders, when I leave the bool out, it places the order properly but cancels immediately citing cancellation due to end of bar. When I add the bool as true (and the other components) it doesn't trade at all:
EnterLongLimit(0, true, 1, Open[-1], "Long 1a");
or
EnterLongLimit(0, true, DefaultQuantity), Open[-1], "Long 1a");Last edited by dsraider; 02-03-2010, 05:14 PM.
Comment
-
Got this:
2/3/2010 6:23:04 PM Entered internal PlaceOrder() method at 2/3/2010 6:23:04 PM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1087.50 StopPrice=0 SignalName='Long 1a' FromEntrySignal=''
2/3/2010 6:23:04 PM Ignored PlaceOrder() method at 2/3/2010 6:23:04 PM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1087.50 StopPrice=0 SignalName='Long 1a' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
Open[-1] is actually on purpose. I want to set my entry at the open of the next bar.
Comment
-
Bertrand!
After a decent night's sleep and a LOT of coffee, I changed EntriesPerDirection to 2 and it now places my limit orders (stops, targets and trails work as well). I was under the impression that 'Entries' referred to sets, not to individual cars. Onto CancelOrder().
Thanks,
Dave
Comment
-
Morning Sir,
EntryHandling is set to UniqueEntries but it just wouldn't work until I changed EntriesPerDirection to 2. Maybe it has to do with the fact that I'm splitting my entries in half so that I can scale out?
Anyway, as you've probably expected from me, entering my CancelOrder() code is preventing orders again. Nothing in the output window but my log shows:
Error on calling 'OnBarUpdate' method for strategy 'RaiderTrendStrat': Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
when my cancel criteria is:
else if (entryOrder1 != null && GetCurrentBid() == Open[-1] + 2 * TickSize)
{
CancelOrder(entryOrder1);
CancelOrder(entryOrder2);
}
Changing Open[-1] to [0] allows it to load but no orders occur. Any hints?
Comment
-
Well, I thought I did it right but it just won't enter. It loads up fine in the Log but entries are missed and TraceOrders shows nothing. Going to start drinking early today...Attached Files
Comment
-
Dave, you want to reset the IOrders also if those are filled, meaning they are 'ready' for the next entry to be taken -
Code:protected override void OnOrderUpdate(IOrder order) { // Checks for all updates to entryOrder. if (entryOrder1 != null && entryOrder1.Token == order.Token) { // Check if entryOrder is cancelled. if (order.OrderState == OrderState.Cancelled || order.OrderState == OrderState.Filled) { // Reset entryOrder back to null entryOrder1 = null; } } // Checks for all updates to entryOrder. if (entryOrder2 != null && entryOrder2.Token == order.Token) { // Check if entryOrder is cancelled. if (order.OrderState == OrderState.Cancelled || order.OrderState == OrderState.Filled) { // Reset entryOrder back to null entryOrder2 = null; } }
Comment
-
Thanks but I'm afraid that didn't do anything. In English, since my signal needs the bar to close and sets the entry at the open of the next bar. If that is 1000 long limit and it doesn't fill, the strat should self-cancel once it hits 1000.50. maybe it's my cancel logic?
Output window:
2/4/2010 3:14:50 PM Entered internal PlaceOrder() method at 2/4/2010 3:14:50 PM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1065.00 StopPrice=0 SignalName='Short 1a' FromEntrySignal=''
2/4/2010 3:14:50 PM Entered internal PlaceOrder() method at 2/4/2010 3:14:50 PM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1065.00 StopPrice=0 SignalName='Short 1b' FromEntrySignal=''
2/4/2010 3:14:51 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Long 1a' Mode=Ticks Value=8 Currency=0 Simulated=False
2/4/2010 3:14:51 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Long 1b' Mode=Ticks Value=8 Currency=0 Simulated=False
2/4/2010 3:14:51 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Short 1a' Mode=Ticks Value=8 Currency=0 Simulated=False
2/4/2010 3:14:51 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Short 1b' Mode=Ticks Value=8 Currency=0 Simulated=False
2/4/2010 3:16:10 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Short 1a' Mode=Price Value=1065 Currency=0 Simulated=False
2/4/2010 3:16:10 PM Amended stop order: Order='NT-00627/Sim101' Name='Stop loss' State=Working Instrument='ES 03-10' Action=BuyToCover Limit price=0 Stop price=1065 Quantity=1 Strategy='RaiderTrendStrat' Type=Stop Tif=Gtc Oco='NT-00415' Filled=0 Fill price=0 Token='f6d25067f4bb4e719a2e92365888b774' Gtd='12/1/2099 12:00:00 AM'
2/4/2010 3:16:10 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Short 1b' Mode=Price Value=1065 Currency=0 Simulated=False
2/4/2010 3:16:10 PM Amended stop order: Order='NT-00629/Sim101' Name='Stop loss' State=Working Instrument='ES 03-10' Action=BuyToCover Limit price=0 Stop price=1065 Quantity=1 Strategy='RaiderTrendStrat' Type=Stop Tif=Gtc Oco='NT-00416' Filled=0 Fill price=0 Token='fe2e9acf55c7496ab97a8120ef63f3dc' Gtd='12/1/2099 12:00:00 AM'
2/4/2010 3:16:10 PM previousPrice = 1065
2/4/2010 3:16:10 PM newPrice = 1065
2/4/2010 3:17:10 PM Cancelled pending exit order, since associated position is closed: Order='NT-00628/Sim101' Name='Profit target' State=Working Instrument='ES 03-10' Action=BuyToCover Limit price=1064 Stop price=0 Quantity=1 Strategy='RaiderTrendStrat' Type=Limit Tif=Gtc Oco='NT-00415' Filled=0 Fill price=0 Token='6f625381cbf9442dbb0d6598ba2e0007' Gtd='12/1/2099 12:00:00 AM'
2/4/2010 3:17:10 PM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00628/Sim101' Name='Profit target' State=Cancelled Instrument='ES 03-10' Action=BuyToCover Limit price=1064 Stop price=0 Quantity=1 Strategy='RaiderTrendStrat' Type=Limit Tif=Gtc Oco='NT-00415' Filled=0 Fill price=0 Token='6f625381cbf9442dbb0d6598ba2e0007' Gtd='12/1/2099 12:00:00 AM'
2/4/2010 3:17:10 PM Cancelled pending exit order, since associated position is closed: Order='NT-00630/Sim101' Name='Profit target' State=Working Instrument='ES 03-10' Action=BuyToCover Limit price=1063 Stop price=0 Quantity=1 Strategy='RaiderTrendStrat' Type=Limit Tif=Gtc Oco='NT-00416' Filled=0 Fill price=0 Token='a7fa6a68ac5a4ee7a4b5166c933de444' Gtd='12/1/2099 12:00:00 AM'
2/4/2010 3:17:11 PM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00630/Sim101' Name='Profit target' State=Cancelled Instrument='ES 03-10' Action=BuyToCover Limit price=1063 Stop price=0 Quantity=1 Strategy='RaiderTrendStrat' Type=Limit Tif=Gtc Oco='NT-00416' Filled=0 Fill price=0 Token='a7fa6a68ac5a4ee7a4b5166c933de444' Gtd='12/1/2099 12:00:00 AM'
PnL was changing under 'Unrealized' but everything else (including the DOM) didn't move.
???
UPDATE: It is now placing orders (you got me) but haven't tested the CancelOrder() part.Last edited by dsraider; 02-04-2010, 02:43 PM.
Comment
-
Dave, ok great - please also add visual checks (for example drawing objects such as dots, arrows) on your conditions evaluating 'true' - this will help you immensly debug those if needed.
For the CancelOrder(), please keep in mind GetCurrentBid / Ask is replaced by the Close value in backtesting, thus may have to test in realtime only with this logic...
Just add to the OnBarUpdate() start -
Code:if (Historical) return;
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
41 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
64 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
41 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment