Login Page - Create Account

Support Board


Date/Time: Mon, 08 Sep 2025 16:32:36 +0000



Post From: order qty being converte to 0

[2025-08-20 11:53:12]
User431178 - Posts: 772
The quantity is only being converted to 0 in your message log output and that is because of error in code.


s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);
LogMsg.Format("Current Position: Qty=%d", PositionData.PositionQuantity);
sc.AddMessageToLog(LogMsg, 1);

Qty=%d is wrong here, PositionData.PositionQuantity is double not integer, so Qty=%f would be used instead


MinOrder.OrderQuantity = 1;
LogMsg.Format("After setting Qty=1: Qty=%u", MinOrder.OrderQuantity);
sc.AddMessageToLog(LogMsg, 1);

Qty=%u is wrong here, MinOrder.OrderQuantity is double not integer, so Qty=%f would be used instead too

https://cplusplus.com/reference/cstdio/printf/


2025-08-20 11:18:11.993 | Chart: AUDUSD[M] 1000 Trades #1 | Study: Manual Order Bypass Test | FINAL RESULT: -8998 *
2025-08-20 11:18:11.993 | Chart: AUDUSD[M] 1000 Trades #1 | Study: Manual Order Bypass Test | Struct works but order submission fails: -8998 *

On top of that, your order will never be submitted in this test as you can't enter orders during recalculation (that's what the -8998 error code is telling you).
-8998 = SCT_SKIPPED_FULL_RECALC

Automated Trading From an Advanced Custom Study: Order Error Constants

Before you get ChatGPT, Claude or whatever to write more code, you could get it to summarize the relevant docs so you have more of an idea of what is happening and why.
Date Time Of Last Edit: 2025-08-20 11:54:17