Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Strategy Fails to Transition from Historical to Real Time

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

    Strategy Fails to Transition from Historical to Real Time

    This is a first attempt to run a strategy real time against a live account using NT 6.5.0.10.

    FIRST PROBLEM

    The strategy failed immediately because it tried submitting an active historical order using the same historical position size and was rejected.

    BUG? NT uses the same size of the active historical order to attempt to enter a position into the live account but gets rejected and the system shuts down.

    So I disabled that in the Options and so that it waits until flat.

    SECOND PROBLEM

    With Options set to wait until flat before trading, the strategy never exited the most recent active historical position.

    5 minutes past when it should have hit the profit target, I reloaded Ninjascript on the chart and it correctly exited the historical position.

    FINALLY

    Finally when there was no active historical trade, the system traded properly. It entered and exited according to the rules and used the correct real time trade size.

    QUESTIONS

    Is there any known bugs around dealing with active historical orders? If not, I can report this under 6.5 beta issues.

    MAJOR CONCERN

    This presents a major problem whenever you need to restarting the strategy due to a software or system failure. If it already has a position, how does it re-synchronize when restarting?


    Sincerely,
    Wayne

    #2
    1) Not sure what you mean. Can you clarify.

    2) Is your system always in? If yes, this could be a problem since it will never be flat. Alternatively, you can do something like "if (Historica) return;" when running live.

    Major Concern
    Would need to understand what you mean with #1 before I can response completely.
    RayNinjaTrader Customer Service

    Comment


      #3
      1) To clarify, I'll walk through the steps that created the problem.
      1. Created a new USDJPY chart with 1 second data and 3 days history.
      2. Applied a strategy at 7:40 am EST using my live MB Trading account.
      3. The strategy already entered a long historical trade at 7:38 am EST using position size of 100000.
      4. NT automatically tried to enter the market long to start out the real time trading using a long entry with position size 100000.
      5. MB Trading rejected this order.
      6. The strategy terminated itself.

      The bug is that NT tries to enter the live account so that the strategy and account positions match. However, it uses the historical position size of the already open strategy instead of the equivalent account position size (which varies per brokerage and account).


      2) Okay, let's assume I make the strategy do: if(Historical) { return }. But what happens if the strategy stops for any reason and I have to restart it while it already had a position active.

      Apparently it won't recognize the live active position and resynchronize so that's a manual step to adjust the account and strategy position to match, right?

      While I love NinjaTraders API for strategy trading, it seems a lot of manual work is required to administer an "automated" strategy.

      Sincerely,
      Wayne

      Comment


        #4
        Thanks Wayne,

        Originally posted by wayneFH View Post
        1)

        The bug is that NT tries to enter the live account so that the strategy and account positions match. However, it uses the historical position size of the already open strategy instead of the equivalent account position size (which varies per brokerage and account).
        This is not true. NT will never submit an order to enter a position in a real-time account in order to synchronize to the strategy position. What is true is that NT convert historical orders to live orders on crossing from historical to live.

        As an example. As you go from historical to live, you have a 100K position long in the strategy with a single stop loss order. Your actual MBT account is flat. What happens is that NT will convert this stop loss order to a live order. Your MBT account will remain flat unless you manually enter a 100K buy order so that your strategy is in sync with your position.

        In your specific situation, there must be something else that is happening. You can check the logs to see what the exact order was and why it was rejected...which is what likely terminated the strategy.


        2) That is correct. You always have to synchronize manually. The problem is that to have a complete closed loop system you have to program for every inevitability and take corrective action. There are sooooo many of these inevitabilites and potentially different actions and many different use models that is becomes a very difficult situation to cover. As a refererence, take a look at TradeStation. They have this problem as well and they have been around much longer than us and they still don't have a solution.
        RayNinjaTrader Customer Service

        Comment


          #5
          1) You are right. I found this reference: in the help. I had remembered it wrong. http://www.ninjatrader-support.com/H...helpguide.html

          So that raises the question of what order was getting submitted.

          Okay, I'll turn on logging in the future to figure out if it happens again. It must be an error in my custom strategy.

          I need to stop assuming problems are NT bugs, don't I?

          2) Good point. So here's the solution. Rather than try to solve every trader's situation. Implement this similar to you excelling Fill strategy for historical data. In other words, proved the code for the default action you already have and allow us users to create our own position shut down handling.

          Then we have the option to cancel only entries or cancel everything and exit all positions or something else more sophisticated like recordt the positions so on restart the strategy can resynchronize.

          In other words, you can make it user definable.

          Sincerely,
          Wayne

          Comment


            #6
            Thanks for the suggestion as well.
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            942 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            4 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            33 views
            0 likes
            Last Post wzgy0920  
            Working...
            X