Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto Strategy in live test generates random number of orders

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

    Auto Strategy in live test generates random number of orders

    Hi fellow traders,

    I have a problem that I'd like some advice:

    In my auto strategy I didn't specify the order quantity, I just use
    EnterLong();
    ExitLong();
    EnterShort();
    ExitShort();

    And on strategy option tab I leave "Set Order Quantity" to "by Strategy". Not very wise, I know. Backtesting always has one order in any position. Live forward testing mostly has one order too, but sometimes it has two or three orders generated randomly I'm yet to see a pattern.

    All my orders have the same entry and exit rules. I'd like to know what is the best way to control the order quantity, in strategy coding or strategy option tab? I don't mind manually modify the order quantity when needed.

    Thank you for your input.

    #2
    leizhenhua, thanks for the post. Is this a reversal strategy you're trading here? Reason I'm asking is that the Enter() method would reverse for you if needed, so there would be no separate Exit() call needed when doing the reverse, this could lead to duplicate positions otherwise in real-time mode.

    Also, it would be important to understand how you start up the strategy for real-time trading (Immediately Submit vs WaitUntilFlat) and if you're syncing your account position correctly up.

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thank you for your reply.

      To your second question, I set Strategy to wait till flat and sync position = true. My strategy is enabled before session starts. Plus, I coded to wait till bars since session > certain number to start generate signal, just to pass the opening volatility. So I don't think these are the reasons. The random order numbers happens during the session and well after strategy enabled.

      To your first question, the strategy is not an always in one. I use a filter so that there are times the position is flat. However, as I exam the strategy, it is possible that when the Exit condition met, the Enter condition met at the same time, too. So it is possible, say when I was in a long position, a short entry generated, so the strategy reversed my position to short; at the same time, maybe a ms later, the exitlong signal generated too, so the strategy sold short again, and I ended up with two short position. And this could happen next time if the circumstance is exactly the opposite and my position just piled up.

      I just looked at the order execution log, and it confirmed my thought. Question is, how to solve this problem?

      In a strategy, when you have multiple sets of conditions and actions, and some of actions could be triggered at exactly the same event (the conditions might be different, but the same event could drive several conditions to be true). I know I can work out a solution to eliminate this scenario, which could mean redesigning the strategy. However, if we can control which action comes first and which action after, would it be the most direct solution that won't compromise the underlying strategy?
      Last edited by leizhenhua; 01-15-2015, 04:22 AM.

      Comment


        #4
        Hi Bertrand, and fellow traders,

        I'm just thinking, is there a entry method that just enters one position, but doesn't reverse existing position? That would be perfect solution to my problem.

        Thanks.

        Comment


          #5
          leizhenhua, thanks for confirming my thought. In the managed mode the Enter() methods would do the reverse for you, only in unmanaged you would simply send the order desired directly to the broker API via the SubmitOrder() call, but the downside would be that there's less management and convenience in tracking avaialble for you through NT. I would rather suggest reviewing the strategy logic design to ensure you would only fire the one needed order, this will also minimize the likelihood running into overfills situations - generally the less orders, the better as you run less changes to see racing order events taking place.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Hi Bertrand,

            Just let you know that I modified the conditions so that duplicated position won't occur, without changing the underlying logic. So far it works fine in live test.

            Thank you for your input.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by trilliantrader, Today, 03:01 PM
            0 responses
            2 views
            0 likes
            Last Post trilliantrader  
            Started by pechtri, 06-22-2023, 02:31 AM
            9 responses
            122 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by frankthearm, 04-18-2024, 09:08 AM
            16 responses
            67 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by habeebft, Today, 01:18 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by benmarkal, Today, 12:52 PM
            2 responses
            19 views
            0 likes
            Last Post benmarkal  
            Working...
            X