Support Board
Date/Time: Mon, 28 Apr 2025 04:13:07 +0000
Post From: Custom Study TOSSignalReaderV2 Fails with Error -8996 (Quantity 0)
[2025-03-31 07:45:09] |
User431178 - Posts: 656 |
1. Your logging messages are wrong. // Detailed order logging before execution LogMessage.Format("Order Details: Symbol=%s, Qty=%d, Type=%d, TIF=%d", newOrder.Symbol.GetChars(), newOrder.OrderQuantity, newOrder.OrderType, newOrder.TimeInForce); newOrder.OrderQuantity is type double not int, Qty=%f would be needed not %d. LogMessage.Format("Initial position check for %s (Chart Symbol: %s): Result=%d, Position Quantity=%d", adjustedSymbol.GetChars(), chartSymbol.GetChars(), positionResult, position.PositionQuantity); position.PositionQuantity is type double not int, Position Quantity=%f would be needed not %d. 2025-03-30 21:38:20.516 | Chart: MNQM25-CME[M] 1 Min #1 | Study: TOS Signal Reader V2 | Failed to execute ShortSignalPlot for [Sim]MNQM25-CME, Error: -8996 2. Error -8996 means you specified an invalid index when using sc.SellEntry and/or sc.SellExit. This is wrong result = sc.SellEntry(newOrder, SendOrdersToTradeService.GetYesNo()); as is this result = sc.SellExit(newOrder, SendOrdersToTradeService.GetYesNo()); SendOrdersToTradeService.GetYesNo() has no place in that function call, it should be a bar index. Here are the doc links for order entry/exit: Automated Trading From an Advanced Custom Study: Submitting and Modifying An Order Through the Advanced Custom Study Interface You could save yourself some time by looking at the trading system examples in sierrachart/ACS_Source/tradingsystem.cpp, that would give you some clues as to where you are going wrong. |