Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Huge issue. Auto strategy placing orders that I think are impossible?

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

    Huge issue. Auto strategy placing orders that I think are impossible?

    Im having a huge huge issue. I was trading with my strategy live today. I have the Immediately submit live working historical orders box checked and My account is not synced. I started the strategy with the live account while my position was flat in the beginning of the day. A buy signal came along and it fired off buying 2 contracts 1331.50. At this point everything looks normal. It came to a sell signal and the strategy did this It sold 1 contract at 1331.75 and then 1 more at 1331.75 and then sold 2 at 1331.75 to "close position" and then sold 2 more at 1331.75 as the normal sell position.

    My strategy is set up to only submit orders of 2. Why did I get two orders of 1 and then my normal order?

    Here is the simple code:

    // Condition set 1
    if (CrossAbove(EMA(57), SMA(226), 1))
    {
    EnterLong(2, "");
    ExitShort("", "");
    }

    // Condition set 2
    if (CrossBelow(EMA(67), SMA(222), 1))
    {
    ExitLong("", "");
    EnterShort(2, "");
    }
    }
    }



    Clearly I have it set to buy and sell in orders of 2. Why did it sell two single orders of 1 contract, THEN close the position and then enter a short position of 2 like the strategy says. I am so confused here.

    #2
    Hi olingerc,

    Your strategy should not try to both enter and exit in the same code block.

    If you want to code a reversal strategy, the Enter methods alone will take care of the closing and opening orders, so you don't need an exit statement there.

    If you do not want a reversal, then you do market position checks before each Enter statement, checking that you are flat before submitting either long or short orders.

    I have the Immediately submit live working historical orders box checked
    With this setting, you should keep in mind it's easy for the strategy position to get out of sync with the account position. If you start the strategy and it reports a long position at startup, the strategies next exit signal could actually be an opening short order on the account.

    To track what your strategy is doing, you should add TraceOrders = true; to the Initialize() method and view output related to strategy orders using Tools > Output Window.
    Last edited by NinjaTrader_RyanM1; 04-21-2011, 02:05 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick response. I did not know a long enter will automatically reverse a short position. To me the code looked like if you enter long 2 you must sell 2 (to get back to flat) and then enter 2 short to be short.

      I think taking out that part of the code will accomplish my goals for this strategy.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rhyminkevin, Today, 04:58 PM
      3 responses
      46 views
      0 likes
      Last Post Anfedport  
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      7 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      14 views
      0 likes
      Last Post 00nevest  
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      50 views
      0 likes
      Last Post futtrader  
      Working...
      X