I would also suggest you add checks for your current market position in your code - http://www.ninjatrader-support.com/H...tPosition.html
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
ExitLongLimit issue.
Collapse
X
-
Hi strategy1, please post your latest code revision. You will need to simplify the code and check where and why you are hitting the 'Internal Order Handling Rules' - http://www.ninjatrader-support.com/H...verview36.html
I would also suggest you add checks for your current market position in your code - http://www.ninjatrader-support.com/H...tPosition.html
-
Here is the code.
Attached is the simplified code.
I am not sure why I am hitting the Order Handling Rules. That's the whole reason for my posts on this issue.
It's probably something small (like it was before), yet it has taken me more than day to debug.
Thanks.Attached Files
Comment
-
Something so small - yet took so long.
Bertrand,
Thanks, I can't believe this took so long to resolve... again.
But how do I now implement the Profit Target?
Also, I noticed that I get this message:
1/2/2009 11:55:00 AM Ignored PlaceOrder() method: Action=Sell OrderType=Limit Quantity=0 LimitPrice=37.15 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
As I understand it - the strategy is trying to exit based on the exit rule being true, but since there is no position the order is being ignored.
Checking the current market position in the same if statement that generates the exit order will eliminate this message as it will not be true if there is no position.
Is it OK however to backtest a strategy that generates this message (i.e. can the results be trusted?)
Thanks
Comment
-
Hi strategy1, you see from this example how important the full code is for us to help you out, small changes can have major impacts on all levels.
You would implement your profit target the same way as you realized your Stop order now. You can use Position.AvgPrice to reference your entry price level - http://www.ninjatrader-support.com/H.../AvgPrice.html
Correct, your exit triggers, but you have no market position check in there to submit it only when a position is present, so it is ignored by NinjaTrader. While this would work, I would suggest adding the market position check to get a as clean result as possible.
Comment
-
Order Generated But Not Shown
Checking through the results on the chart I noticed that an order should have been generated, but wasn't.
I re-ran the strategy just for that symbol and sure enough the log is showing the Order being generated and Placed, yet it is not shown by the Strategy Analyzer.
What could be the reason?
1/7/2009 11:25:00 AM Entered internal PlaceOrder() method at 1/7/2009 11:25:00 AM: Action=Buy OrderType=Limit Quantity=1,000 LimitPrice=46.15 StopPrice=0 SignalName='Buy' FromEntrySignal=''
BOUGHT 46.15 1/7/2009 11:25:00 AM
TARGET 46.6115 1/7/2009 11:25:00 AM
1/7/2009 11:30:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00000/Back101' Name='Buy' State=Working Instrument='RIMM' Action=Buy Limit price=46.15 Stop price=0 Quantity=1,000 Strategy='MorningBreakout' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='9be4bdc1f5be47fbb3c8e1306f052e81' Gtd='12/1/2099 12:00:00 AM'
Comment
-
strategy1,
The reason is stated in your traces. 1/7/2009 11:30:00 AM Cancelled expired order.
Your order has expired and so it was cancelled. You need to keep it alive if you want it to persist through the next bar. Please read the "Order Submission for Entry and Exit Methods - Basic Operation" section of this article: http://www.ninjatrader-support.com/H...tml?Overview36Josh P.NinjaTrader Customer Service
Comment
-
Is it really being cancelled?
Is my order really being cancelled?
As per the trace log, An entry (buy order) is entered but not placed. Am I understanding it correctly?
I've read the section you suggested and I do not see a reason why it would not be placed, since the price is there (as per the chart)
Also, isn't the order alive by default, provided the condition for its execution is true?
Otherwise should I not have orders on other days as well?
Thanks
Comment
-
strategy1,
I do not know what you have for your code. It is very clear from your trace that you did not resubmit your order to keep it alive. If the order is not kept alive it is then expired. When expired it is cancelled. That is what you are seeing.
Entered is the same thing as placed. You placed the order at 11:25. You did not at 11:30. Therefore you are cancelled at 11:30 because it expired.Josh P.NinjaTrader Customer Service
Comment
-
Here is my code.
My code is attached.
As I continued to debug I noticed yet another message:
Ammended open order...
Can you see why some orders are expiring and others are being ammended at exact same time as they are being placed?
ThanksAttached Files
Comment
-
Hi strategy1, from the code you posted you do not keep the limit orders placed 'alive' so they expire at the end of the bar as expected.
Please review this article from our help guide and recode your script - http://www.ninjatrader-support.com/H...verview36.html
Comment
-
I've already reviewed it.
Bertrand,
I already reviewed that article as per Josh's suggestion a few posts ago.
It states:
"By default, orders are kept alive provided that they are re-submitted on each call of the OnBarUpdate() method."
Can you expand on what you mean by saying that "I do not keep the limit orders placed 'alive' "
As per the article suggested, they are alive by default.
Am I missing something?
Thanks
Comment
-
The are alive "provided that they are re-submitted on each call of the OnBarUpdate() method". You are not resubmitting. Therefore they are not kept alive.
For instance, look at your code for EnterLongLimit(). You explicitly prevent your code from resubmitting. This order will always be cancelled if not filled within one bar the way you have it coded. Your Exit() orders on the other hand are limited only by the price action. So if permitted by the price action, those orders are resubmitted and kept alive.Josh P.NinjaTrader Customer Service
Comment
-
Still can't get it to work.
Josh,
I must be missing something. Do you mean I am not resubmitting my order via my use of HasTradedLong variable?
If so, I understand, but it should still be executed, shouldn't it?
"This order will always be cancelled if not filled within one bar the way you have it coded"
But it should be filled within one bar - shouldn't it?
It is being filled on all other days.
What should I do to get this to work?
Thanks
Comment
-
Hi, you place a limit order that will or will not get filled on the bar you have placed it. When it does not get filled at your limit price, it will expire and cannot be filled on the next bars, because it is cancelled and not working in the queue anymore. To achieve this you will need to resubmit it to keep it alive until you got your fill or your entry conditions do not justify placing it anymore.Last edited by NinjaTrader_Bertrand; 01-21-2009, 03:41 PM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
578 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment