Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Real dynamics of limit orders
Collapse
X
-
Thanks for sharing. If I make any progress in this issue I'll let u know. Reading a lot of your threads, it seems clear that NT at this point doesn't allow to reverse positions with limit orders in the same bar if BarOnClose is true. So I imagine the only solution is the difficult unmanaged approach. Well, let's see what can be done for a non advanced user like meLast edited by pstrusi; 12-04-2013, 03:10 PM.
-
Not necessarily.Originally posted by pstrusi View PostThanks for sharing. If I make any progress in this issue I'll let u know. Reading a lot of your threads, it seems clear that NT at this point doesn't allow to reverse positions with limit orders in the same bar if BarOnClose is true. So I imagine the only solution is the difficult unmanaged approach. Well, let's see what can be done for a non advanced user like me
One thing you can do is use OnMarketData() to cancel the pending orders, then use OnExecution() to place your reverse order, once you get confirmation of the orders being cancelled.
There is another technique, where when you get the reversal order, you turn COBC to false, cancel the pending orders, issue the reverse order, then turn COBC back to true.
Comment
-
Koganan, this is the logic flow of the module that I'm applying to the issue reversing positions and its stops with limit orders. Following your way of put it:Originally posted by koganam View PostNot necessarily.
One thing you can do is use OnMarketData() to cancel the pending orders, then use OnExecution() to place your reverse order, once you get confirmation of the orders being cancelled.
There is another technique, where when you get the reversal order, you turn COBC to false, cancel the pending orders, issue the reverse order, then turn COBC back to true.
0. The Script always working with COBC = True
1. Check and cancelling any working order
2. Entering reverse order
3. When new position achieved then entering its Stop order
Maybe NT has some updated that allows work this with COBC= True.
I'm still reviewing its behavior comparing it with a system that reverses without Stops, so far, so good.
Thanks
Comment
-
That works, kind of. Already investigated that. The issue for me is that there is then a one bar delay between getting my signal, and entering the trade. I prefer that my entry comes sooner than a one bar delay: in other words, I want my reversal order placed when the signal is received, not one bar later.Originally posted by pstrusi View PostKoganan, this is the logic flow of the module that I'm applying to the issue reversing positions and its stops with limit orders. Following your way of put it:
0. The Script always working with COBC = True
1. Check and cancelling any working order
2. Entering reverse order
3. When new position achieved then entering its Stop order
Maybe NT has some updated that allows work this with COBC= True.
I'm still reviewing its behavior comparing it with a system that reverses without Stops, so far, so good.
Thanks
IOW, it does not meet the specification of reversing on the same bar.
Comment
-
I understand. Since I work many times with Range Bars chart, it's ok for me.Originally posted by koganam View PostThat works. Already investigated that. The issue for me is that there is then a one bar delay between getting my signal, and entering the trade. I prefer that my entry comes sooner than a one bar delay: in other words, I want my reversal order placed when the signal is received, not one bar later.
Comment
-
Hi Ninjas,
As I commented earlier in this thread I did a little module ( under managed approach ) that allows reversing position with limit orders but where the positions is tied to Stops orders. This is the logic flow of the module that I'm applying:
0. The Script always working with COBC = True
1. Check and cancelling any working order
2. Entering reverse order
3. When new position achieved then entering its Stop order
This works but it has a "flaw" that sometimes appears and it's pretty easy to spot:
Before reversing the script has to cancel orders, thus depending on markets dynamics one can be for a while with a position not protected by any stop. This wouldn't be a worry as long as the Script continues to work, but there are delicate situations that might be a great problem. Imagine for example that your internet provider connection stops its service suddenly, a great problem, big time for sure.
So is there any other way, under managed approach method that allows cancel the stop just when the reversing is occurred ?
Comment
-
Hello pstrusi,
While it would not be possible to cancel the stop loss, you could set the stop loss to a price level that is much further away from the traded price, and then reverse the position after the stop loss has updated and is further away. This would prevent the stop from filling and causing undesired behavior. Then you can have the stop when you need it, then move it further behind the market and not have it fill when you are trying to reverse the position using the method you want.Chelsea B.NinjaTrader Customer Service
Comment
-
Hi Chelsea. Maybe I didn't explain well. What I want is to Reverse a position first, when done then cancelling the old Stop. I think this is the original problem with limit orders: the internal rules doesn't allow a reverse if any stop is working. So this problem is not solved by moving the Stop price much further of traded prices. As I've posted the solution that I've implemented ( immediately reverse after cancelling stops ) works 90% of the reversing, but some times market dynamics slow the procedure. This is why, I'm asking if under managed approach I could do any tweek or something similar in order to do less risky the reversing without old stops working. Do you understand what I ask for ?Originally posted by NinjaTrader_ChelseaB View PostHello pstrusi,
While it would not be possible to cancel the stop loss, you could set the stop loss to a price level that is much further away from the traded price, and then reverse the position after the stop loss has updated and is further away. This would prevent the stop from filling and causing undesired behavior. Then you can have the stop when you need it, then move it further behind the market and not have it fill when you are trying to reverse the position using the method you want.
Comment
-
Hello pstrusi,
You cannot reverse your position when a stop and profit target are working when using a limit order to reverse the position. You can reverse the position with a market order, however, even if the position is protected with a stop and target.
It may be better to use Exit orders instead of SetStopLoss and SetProfitTarget. This is because you can cancel an exit order at any time if needed.
It is possible to use Exit orders very similar to how the SetStopLoss works, in that after the entry fills you can submit an Exit(Long/Short)StopLimit in OnExecution for the stop and an Exit(Long/Short)Limit for the profit target. Then, also in OnExecution, if the stop is hit cancel the target and if the target is hit cancel the stop.
Also, if you were to exit the entry order before your reverse your position, this will also cancel the associate stop loss and profit target automatically if you are using SetStopLoss and SetProfitTarget.Chelsea B.NinjaTrader Customer Service
Comment
-
Yes, I know this, I was just asking in case of any tweek before entering the unmanaged approach.Originally posted by NinjaTrader_ChelseaB View PostHello pstrusi,
You cannot reverse your position when a stop and profit target are working when using a limit order to reverse the position. You can reverse the position with a market order, however, even if the position is protected with a stop and target.
It may be better to use Exit orders instead of SetStopLoss and SetProfitTarget. This is because you can cancel an exit order at any time if needed.
It is possible to use Exit orders very similar to how the SetStopLoss works, in that after the entry fills you can submit an Exit(Long/Short)StopLimit in OnExecution for the stop and an Exit(Long/Short)Limit for the profit target. Then, also in OnExecution, if the stop is hit cancel the target and if the target is hit cancel the stop.
Also, if you were to exit the entry order before your reverse your position, this will also cancel the associate stop loss and profit target automatically if you are using SetStopLoss and SetProfitTarget.
Best
Comment
-
Hi Chelsea,
I'm confused about when to use correctly OnOrderUpdate or OnExecution for these situations, and I'd appreciate your help here:
1. I understand that NT suggests that for triggering Stop/Target orders ( when your entry is filled ) is better to use OnOrderUpdate, BUT which method is the best to trigger and keep updated its Stop/Target orders if you have partial fills? It seems that OnExcecution but when this is used, every time a partial fill happens, Stop orders are submitted with a quantity lower than it should. ( I've posted this issue here: http://www.ninjatrader.com/support/f...ad.php?t=62413 )
2. Which method is the best to detect and cancel orders if a Stop/Target order were hit?
3. If my Entry Orders have its EntryNames, will this help to facilitate cancellations of OCA orders, or I have to code any cancellation ?
My apologies if this sounds repetitive but this is not n easy for a non-advanced programmer
Thanks a lot
Comment
-
Hi Chelsea,Originally posted by NinjaTrader_ChelseaB View PostHello pstrusi,
You cannot reverse your position when a stop and profit target are working when using a limit order to reverse the position. You can reverse the position with a market order, however, even if the position is protected with a stop and target.
It may be better to use Exit orders instead of SetStopLoss and SetProfitTarget. This is because you can cancel an exit order at any time if needed.
It is possible to use Exit orders very similar to how the SetStopLoss works, in that after the entry fills you can submit an Exit(Long/Short)StopLimit in OnExecution for the stop and an Exit(Long/Short)Limit for the profit target. Then, also in OnExecution, if the stop is hit cancel the target and if the target is hit cancel the stop.
Also, if you were to exit the entry order before your reverse your position, this will also cancel the associate stop loss and profit target automatically if you are using SetStopLoss and SetProfitTarget.
When I read your response it seemed to make sense, but now I'm trying to reverse positions with limit orders when I have active Exit Orders and the NT under the manage approach doesn't allow it. I searched in the help guide and I came across with this internal rule:
So the issue and how to reverse a position with limit orders, if there're any Exit Order active is not possible under the manage approach.An order will be ignored if: A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
So, any idea in how to reverse a position under this condition ? as a reminder,my need is reversing position but without cancelling Stops order before fillings, cause market dynamics could rapidly change against you or imagine an interruption of your ADSL provider, very dangerous situationLast edited by pstrusi; 12-16-2013, 09:35 AM.
Comment
-
It seems to me that this entire thread has amplified the NT Help text, telling you multiple times that it cannot be done with the present framework. Some things can be impossible in an absolute sense.Originally posted by pstrusi View PostHi Chelsea,
When I read your response it seemed to make sense, but now I'm trying to reverse positions with limit orders when I have active Exit Orders and the NT under the manage approach doesn't allow it. I searched in the help guide and I came across with this internal rule:
So the issue and how to reverse a position with limit orders, if there're any Exit Order active is not possible under the manage approach.
So, any idea in how to reverse a position under this condition ? as a reminder,my need is reversing position but without cancelling Stops order before fillings, cause market dynamics could rapidly change against you or imagine an interruption of your ADSL provider, very dangerous situation
Comment
-
Hello pstrusi,
1) This depends on what you are trying to do. You mention that you are changing the stop/targets. Are you using Exit orders or SetStopLoss()?
I would generally recommend using OnExecution any time you are relying on fills.
From our help guide on OnOrderUpdate:
http://www.ninjatrader.com/support/h...rderupdate.htmCRITICAL: If you want to drive your strategy logic based on order fills you must use OnExecution() instead of OnOrderUpdate(). OnExecution() is always triggered after OnOrderUpdate(). There is internal strategy logic that is triggered after OnOrderUpdate() is called but before OnExecution() that can adversely affect your strategy if you are relying on tracking fills within OnOrderUpdate().
2) When it comes to identifying a stop loss or a profit target are you using an Exit order or SetStopLoss()?
If you are using SetStopLoss() you can identify this type of order in OnExecution with:
if (execution.Name == "Stop loss")
{
// execute code
Print("Stop Loss Order Hit: " + execution.ToString());
}
if (execution.Name == "Profit target")
{
// execute code
Print("Profit Target Order Hit: " + execution.ToString());
}
3) While you should generally always use signal names if your code is complex, orders can only be cancelled with an IOrder handle. This means that you will be setting the IOrder object to a variable and can also be tracked using that handle.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
85 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
47 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
29 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
32 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
67 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment