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 Shansen, 08-30-2019, 10:18 PM
          24 responses
          938 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          2 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          1 view
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          27 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Working...
          X