Login Page - Create Account

Support Board


Date/Time: Wed, 07 May 2025 15:26:15 +0000



Post From: Beginner ACSIL help please

[2024-11-25 02:43:33]
User745789 - Posts: 377
I hope I don't end up asking too much. I have started from zero knowledge and been able to piece together the below code using youtube and SC documentation.

At 10:45am I want to place the OCO orders as stipulated. It is working so far! Except that it appears to be placing that order repeatedly every millisecond (?) so long as the last bar time is 10:45am.

What I want is for the OCO order to be placed once at the moment the time becomes 10:45am. And then nothing else.

Any guidance would be greatly appreciated. To be honest I am surprised I have even made it this far in a few days.

  SCDateTime BarDateTime = sc.BaseDateTimeIn[sc.Index];
  
  int Hour = BarDateTime.GetHour();
  int Minute = BarDateTime.GetMinute();
  if(Hour == 10 && Minute == 45) {
    
    float BarLow = sc.Low[sc.Index-1];
    float BarHigh = sc.High[sc.Index-1];     

    s_SCNewOrder NewOrder;
    NewOrder.OrderQuantity = 1;
    NewOrder.OrderType = SCT_ORDERTYPE_OCO_BUY_STOP_SELL_STOP;
    NewOrder.Price1 = BarHigh + 1;
    NewOrder.Price2 = BarLow - 1;
    
    NewOrder.TimeInForce = SCT_TIF_DAY;
      
    
    sc.SubmitOCOOrder(NewOrder);
  }

To be honest, I am not sure if the error is the bar time. Because I added the following with a stipulation for "Second", and the orders are still produced repeatedly for the duration of the 15 minute bar.

if(Hour == 10 && Minute == 45 && Second == 0)

And when I set "Second == 1", I dont get any orders placed at all.
Date Time Of Last Edit: 2024-11-25 05:08:33