Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 17:58:57 +0000



Post From: Potential Bug With sc.GetTradePosition?

[2024-05-20 01:56:01]
PS - Posts: 40
I am writing a trading strategy using ASCIL and am not getting the expected functionality from sc.GetTradePosition. I'm unsure if its a bug, or a mistake I'm making. Please see below:

First, I do the following:

s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);
int current_position = PositionData.PositionQuantity;

Then, the first trade is taken. I know a position has been entered as I can see the drawing on a 1m chart after conducting a Bar-Based Backtest.

int current_position is then printed to the logs via:

SCString logMessage;
logMessage.Format("Current Position = %s", current_position);
sc.AddMessageToLog(logMessage, 0);

However, for the entire duration of the backtest, current_position = 0 (according to the logs), despite a trade being taken during the backtest.

Am I doing something wrong here, or is this a bug?

Thank you in advance for your help.