Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Cancels Right Away

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Order Cancels Right Away

    Hi all.

    Using this code shown below. After meeting the "Bars formula" below, an order is submitted, and immediately canceled. I'd like to have the order stay active for the duration of the following bar, using a buy/sell price of the last closing bar (Close[0]), and this has been my experience as the default action with other strategy I've built. However it does not appear to be working with this strategy, and I can't seem to figure out why...

    The time frame I'm using is a 2-min, and caclulateonbarclose = true.


    // Bars formula
    int greenbars=0;
    int redbars=0;
    for (int x=0;x<signalbars;x++)
    {
    if (Closes[1][x]>Opens[1][x])
    greenbars++;

    if (Closes[1][x]<Opens[1][x])
    redbars++;
    }

    // Short Order
    if (
    greenbars==signalbars &&
    tradeshort == true &&
    tradepermission == true
    )

    SE=EnterShortLimit(1,false,tradesize,Close[0],"");
    barNumberOfOrder = CurrentBar;


    // Long Order
    if (
    redbars==signalbars &&
    tradelong == true &&
    tradepermission == true
    )

    LE=EnterLongLimit(1,false,tradesize,Close[0],"");

    #2
    If you do not keep the order alive it will automatically expire and cancel. To prevent this you can either keep the order alive by resubmitting or you can use the liveUntilCancelled parameter set to true. If you choose the latter you will have to use CancelOrder() when you are ready to cancel it.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Right...

      But by default, shouldn't the order stay active until the next bar update, which is 2-min since I'm using a 2-min bar and calculateonbarclose = false?

      Brian

      Comment


        #4
        You are using multi-time frame. You may need to keep it alive on the other BarsInProgress.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks! Think I get it now.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Haiasi, Today, 06:53 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottWalsh, Today, 06:52 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottW, Today, 06:09 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ftsc2022, 10-25-2022, 12:03 PM
          5 responses
          256 views
          0 likes
          Last Post KeyonMatthews  
          Started by Board game geek, 10-29-2023, 12:00 PM
          14 responses
          244 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X