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

Multi-Instrument issues

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

    Multi-Instrument issues

    Hello,

    There's a problem I'm having with multi-instrument strategy/indicator at the moment.

    There's an indicator and strategy I developed for NT7, however the strategy uses internal calculation (same calculation as indicator) instead of using indicator itself.

    When I check for signal, I check newest closed bar (index = 1) every tick (onbarclose = false) and check the position state. If rules are met, I take long position on one instrument, short position on the other. During live conditions trades are taken great, however the historical values are 1 bar late (as if I check bar with index = 2 instead of index = 1) and if I reload the scripts (F5), the "proper" live trades are transformed into historical and are 1 bar late as well.

    Any suggestions where should I look?

    #2
    Hi RobertasJ,

    Thank you for the post.

    All historical values are calculated with the OnBarClose set to true. This is because we do not know what the incoming tick values would have been for any of the bars back. Only the Open, High, Low, Close, and Volume.

    When you are running live and you get trades, then either refresh or restart your strategy it is going to take the old historical trade values and run another backtest on the historical chart data. This is to be expected when using historical data with a strategy. While your strategy will run with OnBarClose set to false, all the historical values will have the OnBarClose set to true.

    Below is a link on the Discrepancies Between Real-time and Backtest
    http://www.ninjatrader.com/support/h...ime_vs_bac.htm

    Please let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hello Cal,

      Thanks for your reply.

      I'm aware of the discrepancies issues you posted about, but I don't think they're related to my problem.

      I check at bar 0 (current bar) every tick IF previous bar's (which already is closed) indicator value is above/below X. In other words, I check non-dynamic value and compare it. All tick by tick checks on current bar will result in same value since previous bar does not change. Having said that, during live conditions it is checked normally, however, when historical values are processed I do not see any issues why it should be 1 bar late since trades are opened on bar close anyway due to the nature of this logical check.

      I've done this before and had no issues (signals were exactly same whether on backtest or live since I checked closed bars), but it's the first multi-time frame strategy/indicator I'm doing and it's the first time I see this issue.

      Looking forward to your reply.

      Comment


        #4
        Hi RobertasJ,

        This is expected when working with Multi-Time Frames.

        Your strategy will reference the different time bars differently from OnBarClose set to true and false.

        Take a look at the link below on Multi-Time frames & Instruments. Please read the section How Bar Data is Referenced
        http://www.ninjatrader.com/support/h...nstruments.htm

        Please let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Hey,

          I'm not working with "Multi-Time Frames", time frame is same for both instruments and is same as main data series, that's why "the one bar late signal" is weird.
          Last edited by RobertasJ; 06-04-2013, 07:31 AM.

          Comment


            #6
            Hi RobertasJ,

            Can you please post a screen shot of the error you are seeing with your strategy?

            To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file. Click Reply in the Forum and then Go Advanced. Click the Paperclip on the top toolbar to attach an image.

            For detailed instructions please visit the following link

            http://take-a-screenshot.org/

            I look forward to assisting you further
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Here's the screenshot with the problem. I'm using index 1 to check the value, however it acts as if I operate with index 2. Again, it's all good during live conditions.

              I marked just one place, but you can easily see that all of the trades suffer from this.
              Attached Files

              Comment


                #8
                Hi RobertasJ,

                Thank you for the screenshot.

                Your trades are going to show the signal one bar later because the OnBarClose is set to true when backtesting.

                What is happening is that when a bar closes the strategy then runs the calculations and if the conditions are met, the signal will show on the bar being built. If you set your strategy's OnBarClose to true you would see this behavior with the real time bars.

                Though the condition may have been met during that past bar being built, the program does not recognize that since all we know of the historical data is the OHLCV prices of the bar.

                Please let me know if I can be of further assistance.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  What is happening is that when a bar closes the strategy then runs the calculations and if the conditions are met, the signal will show on the bar being built. If you set your strategy's OnBarClose to true you would see this behavior with the real time bars.
                  Not sure we understood each other.

                  Logic is : when bar closes strategy checks NEWEST closed bar (index = 1) and enters trades if rules is met (x > indicator value[1]). If I run the strategy not as a multi-instrument strategy, all is fine, trade is taken immediately upon bar close be it backtesting or live. The multi-time frame addition to the strategy is what made these signals one bar late.

                  Though the condition may have been met during that past bar being built, the program does not recognize that since all we know of the historical data is the OHLCV prices of the bar.
                  Strategy does not care if condition has been met while past bar was being built, it checks already formed bar (something[1] if I may), it never checks live bar at any point. That's why I don't need to use OnClose = true, since I do it manually in the strategy.

                  Comment


                    #10
                    Hi RobertasJ,

                    Would send me your Strategy so I can test it out on my end?

                    Please send a request to Support[at]ninjatrader[dot]com with the Strategy as an attachment
                    Please put ATTN CAL and reference this post.

                    You can find your strategy file on your PC in -
                    • (My) Documents > NinjaTrader 7 > bin > custom > Strategy


                    Thank you for your patience
                    Cal H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by inanazsocial, Today, 01:15 AM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_Jason  
                    Started by rocketman7, Today, 02:12 AM
                    0 responses
                    10 views
                    0 likes
                    Last Post rocketman7  
                    Started by dustydbayer, Today, 01:59 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post dustydbayer  
                    Started by trilliantrader, 04-18-2024, 08:16 AM
                    5 responses
                    23 views
                    0 likes
                    Last Post trilliantrader  
                    Started by Davidtowleii, Today, 12:15 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post Davidtowleii  
                    Working...
                    X