Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 00:43:10 +0000



[Programming Help] - %d, %s; %f ?

View Count: 598

[2023-03-07 11:40:06]
BenjFlame - Posts: 324
Hi,
When logging with Format() I was thinking that those were just place holders, but it seems it's not that simple since sometimes passing a value with the wrong % won't work.

What are all the %xx there is? Where to learn about it?
[2023-03-07 12:19:30]
User431178 - Posts: 544
ACSIL Programming Concepts: SCString Methods

Search printf using your preferred search engine

or look here

https://cplusplus.com/reference/cstdio/printf/
[2023-03-07 13:53:34]
BenjFlame - Posts: 324
ok thanks. Here is the code I'm using:


if (sc.MenuEventID == 6)
{


s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = 1;
NewOrder.OrderType = SCT_ORDERTYPE_MARKET;
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
int Result = sc.BuyEntry(NewOrder);

// Order data
s_SCOrderFillData OrderFillData;
sc.GetOrderFillEntry(sc.GetOrderFillArraySize() - 1, OrderFillData);

// Log
SCString DebugMessage;
SCString symbol = OrderFillData.Symbol;
uint32_t OrderQuantity = OrderFillData.Quantity;


DebugMessage.Format(
"OrderID: %u, Symbol: %s, FillTime: %s, Type: %u, Quantity: %u, FillPrice: %f, PositionQuantity: %u; IsSimulated: %u",
OrderFillData.InternalOrderID,
symbol,
OrderFillData.FillDateTime,
OrderFillData.BuySell,
OrderQuantity,
OrderFillData.FillPrice,
OrderFillData.TradePositionQuantity,
OrderFillData.IsSimulated
);
sc.AddMessageToLog(DebugMessage, 1);

}

Several problems:

- Symbol doesn't seem to display a string... it displays a binary character. Data is supposed to be a string, so I don't know why.
- Same problem for Fill time: how to display that one ?

Last: Position quantity is always 0. Even if I stack orders (I'm in simulated environment).

If you have clues on how to solve theses... thank you
[2023-03-07 14:47:25]
User431178 - Posts: 544
Here is some more complete information, maybe it is helpful - https://en.cppreference.com/w/cpp/io/c/fprintf

Symbol doesn't seem to display a string... it displays a binary character. Data is supposed to be a string, so I don't know why.
You would need to use symbol.GetChars() as functions expects char* not SCString

Same problem for Fill time: how to display that one
For converting SCDateTime to string, take a look at sc.DateTimeToString

sc.DateTimeToString()

Last: Position quantity is always 0. Even if I stack orders (I'm in simulated environment).
TradePositionQuantity is double not unsigned int, i.e. f not u
Date Time Of Last Edit: 2023-03-07 14:48:12
[2023-03-15 12:04:24]
BenjFlame - Posts: 324
Note for self, print:

typeid(a).name(), where a is a variable name.

to know the actual type.
Date Time Of Last Edit: 2023-03-15 12:04:40

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account