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 Position.MarketPosition not set after strategy restart.

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

    Strategy Position.MarketPosition not set after strategy restart.

    I have recorded a video of the problem I'm trying to describe here:


    A strategy creates a long position. When I stop and start the strategy the historical backfill causes the strategy to submit the orders again. This is expected although not wanted. I wrote about that problem here:
    I have a strategy that holds for long periods of time and I'd like to be able to restart the strategy while it's in a position. This strategy is running Calculate.OnPriceChange. Using the provided StartBehaviors I don't see a setting that will allow the strategy to restart running such that it will NOT submit another ENTRY


    The other (new) problem is that the strategy position is NOT Position.MarketPosition == MarketPosition.Long as it should be. There are no chart markers ( despite being enabled ) and the Strategies tab shows that the strategy is Flat.
    In the video in the 1st link above I restart the strategy at about 1 1/2 minutes into the video. You can see that EnterLong is called again, the Replay account goes from 2 contracts to 4 contracts. but the strategy position remains flat. I expect the strategy position to be long. Is that correct? Shouldn't the strategy position be long?

    #2
    Hi Brillo, thanks for your post.

    It looks like this might be caused by Visual Studio debugging. Are you able to reproduce the problem by starting/stopping your strategy normally without break points?
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Same problem running without Visual Studio involved. This new video quickly reproduces the problem running without debugging.

      Comment


        #4
        I attached a strategy that demonstrates the issue. Run it in Market Replay. 1440 min bars. ES or MES. I ran on MES 12-19 starting 12/2/2019. After it gets a position slow down MR and use the Strategies Enabled checkbox in the Control Center to switch it on and off. The account position will climb.
        One thing that's different though: the chart markers for the latest order appear in this version. ( I can't send you the commercial version I'm working on).
        Attached Files

        Comment


          #5
          Hello Brillo, thanks for your reply.

          There must be some aspect of the original script that has an issue because the test script here is not taking any positions on ES 03-20 from 02/24 to 02/28. ES 12-19 data is not available anymore through the market replay servers. There are a few parts of the script that are not supported such as the inheritance system you have implemented. Strategies and indicators already use a complex inheritance system so doing anything further will not be supported and the idea for this strategy would need to be implemented without this for me to help any further. With the current script, you should use Prints to find why the strategy is not making the same orders in history that it made in real-time; this is what I am seeing from the enable/disable/re-enable, It's doing something in real-time that is not being picked up on in historical mode.

          Kind regards.


          Chris L.NinjaTrader Customer Service

          Comment


            #6
            New script attached. I removed the superfluous code.
            new video here:

            I used ES 03-20 on 2/11/2020. 5 minute chart.
            Attached Files

            Comment


              #7
              Hi Brillo,

              I tested your latest sample but I am still not getting what you are seeing. See this video of my test:



              Below is a copy/paste on how to do this:

              To create a clean installation to export your NinjaScript objects from please follow the instructions below:
              1. Go to Help > License Key and copy and paste your License Key into a text document
              2. Export the code you want as the final export as source code
              3. Exit the platform
              4. Go to (My) Documents > rename the 'NinjaTrader 8' folder to 'NinjaTrader 8.Prev'.
              5. Then re-install from the following link: http://ninjatrader.com/GetStarted
              When you reinstall it will recreate the user folder you had just renamed with only stock files.

              Now you can start the platform and import the source code for the item you want to export as a compiled assembly. Because there are no other items in this installation, only the item you want to export would be included.

              To switch between the two installs; shut down NinjaTrader > rename the new installation to 'NinjaTrader 8.Dev' under (My) Documents > then rename the 'NinjaTrader 8.Prev' to 'NinjaTrader 8'. NinjaTrader looks for the user folder named NinjaTrader 8 specifically.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hi Chris. I watched your video. If you watch my video you'll notice that I speed up MR to max and start and stop the strategy quickly several times then slow it back down. In your video I don't see you doing this. Also it happens more easily on max then after it starts happening you can slow it down to normal speed and it continues to happen. also in your video it looks like its taking a long time to load.
                I will try your clean install suggestion and let you know the result as soon as I can get to that.

                Comment


                  #9
                  Hi Brillo,

                  The speed here should not matter, all the same data is being processed. It's taking a long time to load because I have Tick Replay enabled.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    The conditions I used is no tick
                    replay and speed up the playback then after it starts happening slow it down and it continues to happen.

                    Comment


                      #11
                      I'm trying to setup a new instance of NT as per your instructions. I'm also using a separate computer from the one I produced the issue on before. I'm not able to download the market replay data needed for the test. I could copy existing files over from the other computer but I don't want to do that. Instead I want to download it so that it's guaranteed to be the same as yours. See attached video for what I'm seeing.

                      Comment


                        #12
                        Hello Brillo,

                        It looks like you are downloading historical tick and minute data and then looking for this where Market Replay data is saved. This is not market replay data and does not appear in the replay folder.

                        If you download Market Replay data in the Get Market Replay data section instead of historical data, do you have the same issue?

                        Below is a link to the help guide on how to download Market Replay data (not historical data which is completely different).
                        https://ninjatrader.com/support/help...jaTraderServer
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jpapa, Today, 07:22 AM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by kevinenergy, 02-17-2023, 12:42 PM
                        116 responses
                        2,758 views
                        1 like
                        Last Post kevinenergy  
                        Started by franatas, 12-04-2023, 03:43 AM
                        7 responses
                        106 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by Jltarrau, Today, 05:57 AM
                        3 responses
                        9 views
                        0 likes
                        Last Post Jltarrau  
                        Started by f.saeidi, Today, 05:56 AM
                        2 responses
                        9 views
                        0 likes
                        Last Post NinjaTrader_Erick  
                        Working...
                        X