Login Page - Create Account

Support Board


Date/Time: Thu, 23 Jan 2025 09:25:03 +0000



Post From: How to limit the number of open trades

[2018-11-13 23:49:10]
Yoda - Posts: 106
Thank you for the suggestion. But unfortunately adding parentheses did not help. I think the issue is that Quantity is not being populated or is being cleared by the time Buy and Sell is being called. Although I don't think it's necessary since Quantity should not be changing until it's called again, I did assign Quantity to a Persistent variable... but that didn't help either. The following is a snip-it code I am using:


s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);

int Quantity = PositionData.PositionQuantity; // Access the quantity

int& Quantity_Persist = sc.GetPersistentInt(6);
  
Quantity_Persist = Quantity;

...

// Buy Order

if ((Quantity == 0) && (sc.CrossOver(Cross_CloseOrLow, LowOfDay) == CROSS_FROM_TOP))
{
Result = (int)sc.BuyOrder(NewBuyOrder);
...

SCString DebugString;
DebugString.Format("Quantity: %d, Quantity_Persist: %d", Quantity, Quantity_Persist);
sc.AddMessageToLog(DebugString, 0);
}