Login Page - Create Account

Support Board


Date/Time: Thu, 17 Jul 2025 10:32:13 +0000



[Programming Help] - LifeCycle of sc.SupportTradingScaleOut in a study?

View Count: 71

[2025-07-14 23:56:37]
rajeshh - Posts: 17
Hello: I am trying to understand what it means to switch the values of sc.SupportTradingScaleOut in a study? Can it only be set once for a run of the study? I have a case where I want to be able to scaleOut during the lifetime of a bar except on the bar close, when I may place an opposite order with attached orders in my study.

I have tried:

sc.SupportTradingScaleIn = 1;
  
  
  if (sc.GetBarHasClosedStatus() != BHCS_BAR_HAS_CLOSED)
    sc.SupportTradingScaleOut = 1;
    
  else
  {
    sc.SupportTradingScaleOut = 0;
//Submit order to create an opposite order with attached orders does not create attached orders, only the opposite order.

If I always have
sc.SupportTradingScaleOut = 0;
, then when the opposite order is created, it also has attached orders. But this means I cannot use the ScaleOut at all.
Date Time Of Last Edit: 2025-07-15 01:53:15
[2025-07-15 02:34:10]
ForgivingComputers.com - Posts: 1084
I want to be able to scaleOut during the lifetime of a bar except on the bar close, when I may place an opposite order with attached orders in my study.

Change

BHCS_BAR_HAS_CLOSED

to

BHCS_BAR_HAS_NOT_CLOSED

sc.SupportTradingScaleIn = 1;

if (sc.GetBarHasClosedStatus() != BHCS_BAR_HAS_NOT_CLOSED)

sc.SupportTradingScaleOut = 1;

else

sc.SupportTradingScaleOut = 0;

//Submit order to create an opposite order with attached orders does not create attached orders, only the opposite order.


[2025-07-15 04:20:58]
rajeshh - Posts: 17
In which case != also changes to ==, correct?
[2025-07-15 10:18:04]
rajeshh - Posts: 17
I have tried this, and still the same behavior -

  if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED)
    sc.SupportTradingScaleOut = 1;
    
  else if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
  {
    sc.SupportTradingScaleOut = 0;
//Submit order to create an opposite order with attached orders does not create attached orders, only the opposite order.


[2025-07-15 13:44:29]
ForgivingComputers.com - Posts: 1084
Yes that is the code I meant to use. Not sure why it isn't working for you.
[2025-07-17 00:29:15]
@sstfrederik - Posts: 408
it is likely that the trade is not fully processed and you already set ScaleOut back to 1. you should likely check for the order to be in SCT_OSC_OPEN status before switch the ScaleOut state.

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

Login

Login Page - Create Account