SellShort limit orders works fine and this is surprice for me, I didn't expect.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
ExitLongStop & ExitLongLimit
Collapse
X
-
Originally posted by nordseven View PostWhen i'm use ExitLongStop() with ExitLongLimit(), ExitLongLimit() always have been Cancelled. Why?
My onOrderUpdate() code:
Code:[LEFT]if (myEntryOrder != null && myEntryOrder == order) { if (order.OrderState == OrderState.Filled) { if (myStopOrder != null) { CancelOrder(myStopOrder); } if (myProfitOrder != null) { CancelOrder(myProfitOrder); } myStopOrder = ExitLongStop(0, true, qty, stopPrice, "long [B][COLOR=Red]stop[/COLOR][/B]", "long position"); myProfitOrder = ExitLongLimit(0, true, qty, profitPrice, "long [COLOR=Red][B]target[/B][/COLOR]", "long position"); myEntryOrder = null;[/LEFT] } }
After moving this code to OnExecution, remove these lines,
Code:if (myStopOrder != null) { CancelOrder(myStopOrder); } if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
Last edited by bltdavid; 02-27-2016, 11:22 AM.
Comment
-
I'm tried to use onExecution() before, but don't changing name (long stop, long profit). Now it works, thank you!
Little question!
If i'm move everything to onExecution() why i must remove lines
Code:if (myStopOrder != null) { CancelOrder(myStopOrder); } if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
Last edited by nordseven; 02-29-2016, 08:52 AM.
Comment
-
Originally posted by nordseven View PostI'm tried to use onExecution() before, but don't changing name (long stop, long profit). Now it works, thank you!
Little question!
If i'm move everything to onExecution() why i must remove lines
Code:if (myStopOrder != null) { CancelOrder(myStopOrder); } if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
If they are not null at this point, inside OnExecution, you actually have a bigger problem.
Think about it carefully: why possibly would a leftover stop or target still exist such that you need to cancel it just before submitting a new stop and target order? That's not how it (**) works.
(**) By "it" I mean the flow of order management, or in other words: the dance between OnOrderUpdate and OnExecution and "who sets who to null, and when".
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by rocketman7, Today, 01:00 AM
|
0 responses
1 view
0 likes
|
Last Post
by rocketman7
Today, 01:00 AM
|
||
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
74 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
Comment