Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 04:26:16 +0000



[User Discussion] - Turn off auto trading in acsil on Friday afternoon

View Count: 1851

[2013-06-02 18:13:07]
fhvtrading2 - Posts: 11
Hi.
I have a working auto strategy which will flatten somewhere on friday afternoon. How do I make sure it will not enter a new trade after that in case I can not manually turn off autotrading?

I tried using the following code, but am not sure if the sc.SendOrdersToTradeService = false; works. Currently I turn it on as a study setting. I prefer to keep that switch instead of turning it to true inside the strategy.

Hope you have a pointer. Thanks.

example code:

sc.SendOrdersToTradeService = SendOrdersToService.GetYesNo();

SCDateTime SCDateTimeVariable = sc.BaseDateTimeIn[sc.Index];
  
  if (SCDateTimeVariable.GetDayOfWeek() == FRIDAY && sc.BaseDateTimeIn[sc.Index].GetHour() == 16 && sc.BaseDateTimeIn[sc.Index].GetMinute() == 00 && PositionData.WorkingOrdersExist)
  {
    sc.FlattenAndCancelAllOrders();
      
  }
  else if (SCDateTimeVariable.GetDayOfWeek() == FRIDAY && sc.BaseDateTimeIn[sc.Index].GetHour() == 16)
  {
    sc.SendOrdersToTradeService = false;
  }
[2013-06-03 17:42:00]
vegasfoster - Posts: 444
I think you want to change the elseif to if, because you are doing two separate things, then add an else to the second if statement where it equals your bool input.
[2013-06-03 19:44:43]
ejtrader - Posts: 688
As Vegasfoster suggested - probably you try this instead (not tested). Alternately - you can try exploring the usage of local time as well (NOW related functions).

Thanks


sc.SendOrdersToTradeService = SendOrdersToService.GetYesNo();

SCDateTime SCDateTimeVariable = sc.BaseDateTimeIn[sc.Index];

if (sc.SendOrdersToTradeService && SCDateTimeVariable.GetDayOfWeek() == FRIDAY && sc.BaseDateTimeIn[sc.Index].GetHour() == 16 && sc.BaseDateTimeIn[sc.Index].GetMinute() == 00)
{
if(PositionData.WorkingOrdersExist) sc.FlattenAndCancelAllOrders();
sc.SendOrdersToTradeService = false;
}

Date Time Of Last Edit: 2013-06-03 19:47:11
[2013-06-16 22:41:09]
fhvtrading2 - Posts: 11
thanks. that makes sense.
[2014-01-11 15:31:08]
fhvtrading2 - Posts: 11
The following is what works for me.

// flatten and turning off orders to trade service when its friday 1600
  sc.SendOrdersToTradeService = SendOrdersToService.GetYesNo();

  SCDateTime SCDateTimeVariable = sc.BaseDateTimeIn[sc.Index];

  if (sc.SendOrdersToTradeService == 1 && SCDateTimeVariable.GetDayOfWeek() == FRIDAY && sc.BaseDateTimeIn[sc.Index].GetHour() == 16)
  {

    if(PositionData.WorkingOrdersExist) sc.FlattenAndCancelAllOrders();
    
    SendOrdersToService.SetYesNo(false);
  }
  
  // turning it back on in case we forget to manually set it back on Monday
  if (sc.SendOrdersToTradeService == 0 && SCDateTimeVariable.GetDayOfWeek() != FRIDAY)
  {
    SendOrdersToService.SetYesNo(true);
  }

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

Login

Login Page - Create Account