Support Board
Date/Time: Mon, 21 Apr 2025 16:13:05 +0000
[Programming Help] - TradeOrder not matching PositionData
View Count: 145
[2025-02-27 21:53:41] |
LTSys - Posts: 68 |
Hi, Got an issue with the code saying there are no orders open when there is an open order. Running on Sim1 account here are the steps to replicate this issue... 1. Buy 10,000 EURUSD with attached stop/limit orders. 2. Edit attached stop/limit orders to close 1,000. 3. Move stop/limit orders close to market so they get hit. 4. When stop or limit is hit the order will have 9,000 remaining but... Calling sc.GetOrderForSymbolAndAccountByIndex(...) returns no orders. Calling sc.GetTradePositionForSymbolAndAccount(...) returns correct position of 9,000. Please see attached screen shot. You can see the order on the chart but Trade Orders Window has no orders. Shouldn't calling sc.GetOrderForSymbolAndAccountByIndex(...) return the open order? Could support confirm if this is a bug? TIA Date Time Of Last Edit: 2025-02-27 22:19:43
|
![]() |
[2025-02-27 22:53:11] |
User431178 - Posts: 652 |
Not a bug. Please see attached screen shot. You can see the order on the chart but Trade Orders Window has no orders.
You're mixing up order and position, what you see on the chart is the position line not an order. If you want to reduce the open position from 10000 to 9000 then you need to submit a new order to perform that action, not edit the attached stop/target. |
[2025-02-27 22:55:49] |
User431178 - Posts: 652 |
Automated Trading From an Advanced Custom Study: Entry and Exit Order Action Functions
|
[2025-02-27 23:07:51] |
LTSys - Posts: 68 |
you need to submit a new order to perform that action, not edit the attached stop/target.
Thanks for the reply. Why are the attached stop/limit orders modifiable then? |
[2025-02-27 23:54:50] |
User431178 - Posts: 652 |
Why are the attached stop/limit orders modifiable then?
Why would they not be modifiable, every order is modifiable. If you do reduce the quantity of the existing target/stop to less than the position size, then you will need to submit a new stop/target order for the remaining quantity. It is easier to simply submit an exit order for the desired quantity, as then the orders attached to the position will be automatically reduced accordingly. You can edit/manage the orders/system however you want, just some ways are easier than others. There is plenty of info in the docs. Automated Trading From an Advanced Custom Study: General Information about Trading From an Advanced Custom Study |
[2025-02-28 00:11:25] |
LTSys - Posts: 68 |
So when an attached stop or limit order is hit, the parent order is closed regardless if the stop or limit quantity that was filled is lower than the initial parent order quantity... and the remaining position still remains? That's a bit different than other platforms I've coded for so it threw me off. Thanks for clarifying! Date Time Of Last Edit: 2025-02-28 00:39:02
|
[2025-03-01 18:54:30] |
ForgivingComputers.com - Posts: 1042 |
So when an attached stop or limit order is hit, the parent order is closed regardless if the stop or limit quantity that was filled is lower than the initial parent order quantity... and the remaining position still remains?
No. The Parent Order was filled, leaving a position of 10,000. There is no parent order any more. The Trade Orders window will confirm only a stop and target order. If a stop or target is hit with a quantity of 1000, it creates a sell order of 1000, and the position is now 9000. The other order is canceled, and there are no open orders, just a position of 9000. |
[2025-03-01 21:39:59] |
LTSys - Posts: 68 |
Thanks for the help. Appreciate it!
|
To post a message in this thread, you need to log in with your Sierra Chart account: