Support Board
Date/Time: Sun, 09 Feb 2025 00:51:50 +0000
[Programming Help] - Datatypes double not int on 64 bit version, here s_SCPositionData
View Count: 743
[2020-08-05 15:32:22] |
TeeJay - Posts: 123 |
Sadly your documentation is not actual ob s_SCPositionData, as it seems you are using double instead of int for all Quantity types. There are also some newer fields in the structure which are not documented. I don't know if they are ready to use yet, but the data type change is productive for sure and it made me some trouble I could only figure out when I checked the sources, as I was insisting that the quantities are int. Would be nice if the documentation could be updated, thanks The codepart in scstructures.h is #ifdef _WIN64
typedef double t_OrderQuantity32_64;//TODO: Use this only when change to SCDateTimeUnix #else/* #ifdef _DEBUG typedef double t_OrderQuantity32_64; #else*/ typedef int t_OrderQuantity32_64; //#endif #endif Edit : On top of that I have the question what is the reason for sc.GetTradePosition is always returning 1, even if there is absolutely no position for the instrument/symbol? How determine this best then if there is no position? Check Symbol in s_SCPositionData for being empty? I really don't see this as programming help here but rather an explanation how to handle a function that returns a found if there is no result. Thanks Date Time Of Last Edit: 2020-08-05 16:14:04
|
[2020-08-05 16:43:48] |
ForgivingComputers.com - Posts: 999 |
I have noticed this change also as it showed up in Brett Johnson's ToolKit (which is full of great examples of ACSIL). I ended up casting the PositionData.PositionQuantity to int: sc.GetTradePosition(PositionData);
int OpenQty = (int)PositionData.PositionQuantity; I think this was done to support fractional orders for Forex and other markets. |
[2020-08-05 16:49:30] |
TeeJay - Posts: 123 |
Yea it is no problem of course if you know but I was curious if I am too dumb putting out an integer into a string after nearly 3 decades of C++ programming or if the function was simply malfunctioning. Luckily, both is not the case.
|
[2020-08-05 16:58:21] |
ForgivingComputers.com - Posts: 999 |
what is the reason for sc.GetTradePosition is always returning 1, even if there is absolutely no position for the instrument/symbol? How determine this best then if there is no position?
sc.GetTradePosition returns a 1 when the function was able to get the position, not that there is a position of 1. When you are flat, you have a position with a quantity of zero. To check the quantity of the position, use the result of sc.GetTradePosition(PositionData): s_SCPositionData PositionData; sc.GetTradePosition(PositionData); int OpenQty = (int)PositionData.PositionQuantity; if (OpenQty != 0) { // OpenQty : Positive for Long, Negative for Short } else // No position |
[2020-08-05 17:06:27] |
TeeJay - Posts: 123 |
I did not say that there is a position of 1, I did say that it returns 1, regardless if there is a position or not. So there is no 'not found' or 'no position' return code. That is a difference. When I am flat I have no position, for real :):) But regardless of that thanks for your message. I will do it checking against an empty symbol or as you say a zero quantity then. Seems to be the work around for this. |
[2020-08-05 17:07:21] |
ForgivingComputers.com - Posts: 999 |
Would be nice if the documentation could be updated, thanks
I don't know if you marked this [Programming Help] or if Sierra did. They have stated that they don't reply to posts marked this way, so if you want them to change anything, it may be best to remove this tag. |
[2020-08-05 17:14:19] |
TeeJay - Posts: 123 |
I did not, and it is and was no question for programming help. The first is simply an undocumented change. And the edit was, as I wrote to it, also not a question how I do something primarily as rather the question why a function returns the same value if finding something or not, and why I should check certain data fields to determine what should be done with a return code. But whatever. I will do it either my way or your way. Both will work. It is just completely illogical. |
To post a message in this thread, you need to log in with your Sierra Chart account: