Support Board
Date/Time: Fri, 27 Dec 2024 04:47:09 +0000
Post From: ACSIL OrderStatusCode == SCT_OSC_OPEN not valid for manual market orders
[2024-10-26 09:24:23] |
User431178 - Posts: 556 |
This condition if (order.OrderStatusCode == SCT_OSC_OPEN ) is true for manually placed buy limit and sell limit orders. However, this condition is not true for manually placed *market* orders. What happens when you execute a market order? It is filled immediately at the next available price, therefore order status code would be SCT_OSC_FILLED. SCT_OSC_OPEN means it is still modifiable. If you are wanting to exit the position, why do you need to find the order? You can easily find the position size and use that as the quantity for an oppsing order. Do I need to use AutoLoop = 1 to calculate the EMA In general no, but based on your actual code, yes. To use Autoloop = 0, you would need to create loop for EMA calculation. // Only execute on new data to prevent repeated execution on the same tick if (sc.Index < sc.ArraySize - 1) return; // Calculate EMAs only once per tick for efficiency sc.ExponentialMovAvg(sc.BaseData[SC_LAST], EMA5, sc.Input[0].GetInt()); sc.ExponentialMovAvg(sc.BaseData[SC_LAST], EMA8, sc.Input[1].GetInt()); This is problematic, your EMAs will not be calculated on chart recalculation, only running forwards (starting from the last bar at the time of recalculation). const int maxOrdersToCheck = 100; int orderIndex = 0; while (orderIndex < maxOrdersToCheck && sc.GetOrderByIndex(orderIndex, order) != 0) What happens if there are more than 100 orders in the memory? If they are organized chronologically, 0 being the oldest, then the system will break when you exceed 100 orders. |