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

Two separate logics in the same strategy (each uses its own different time fram)

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

    Two separate logics in the same strategy (each uses its own different time fram)

    I have two separate logics in one strategy. Each has its own differemt time bars.

    Primary uses 10m
    Secondary uses 1m

    There is a custom variable switch that I use to switch between one or the other. In no occasion can the two run simultaneously.

    I have added BarsArray[1] and closes[1][0] for the indicators for the secondary logic and it seems to beexecuting properly.

    I however have not set anything in specific (other than the standard condition rules) for the primary and they don't appear to be executing properly.

    I did a test run on market replay and it appears tha, though the switch between the two logic is working properly, the Primary logic is executing simultaneously on the 10m and the 1m time bars.

    Should I add BarsArray[0] and Closes[0][0] to all indicators and conditions that are related to the primary logic as well?

    #2
    Hello nikolaalx,

    Thank you for your post.

    Your assessment is correct, you would also need to ensure you are performing BarsInProgress checks to ensure the calculations are performed on the correct bars: http://www.ninjatrader.com/support/h...inprogress.htm

    Please let me know if you have any questions.

    Comment


      #3
      I did the above, and when in real trading, it appears to be functioning properly.

      When however backtested, the results are not true. I have the feeling that the 10min and 1min bars are merged into one, which causes compromised results.

      Comment


        #4
        Hello nikolaalx,

        Thank you for your response.

        You can take a look at the discrepancies between real-time and backtesting at the following link: http://www.ninjatrader.com/support/h...ime_vs_bac.htm

        Please let me know if you have any questions.

        Comment


          #5
          I am aware of the difference between historical and real time data.

          When backtesting, my strategy produces hundreds of trades per day.

          When done in real time, the trades are no more than 2-3 per day.

          This is what I mean by "discrepancy" and not slight entry/exit price deviation which is normally seen when comparing historical with real time trading.

          Comment


            #6
            Hello nikolaalx,

            Are you running the strategy in real-time with CalculateOnBarClose = false?

            Comment


              #7
              I always use CalculateOnBarClose = true, as otherwise I get false signals.

              Comment


                #8
                Hello nikolaalx,

                Thank you for your response.

                Do have an example I can test for in the Strategy Analyzer and real-time data?

                Comment


                  #9
                  Yes, please tell me to which email I should send the strategy export?

                  Please test it for FB.

                  Keep in mind that the problem occurs when trading in real time with an IB connection, so I am not sure whether market replay would replicate the issue.

                  I think this is a compatibility issue between NT and IB.

                  Comment


                    #10
                    Hello nikolaalx,

                    Thank you for your response.

                    To test I will need the .cs file for the strategy located in the following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Strategy

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by love2code2trade, Yesterday, 01:45 PM
                    4 responses
                    28 views
                    0 likes
                    Last Post love2code2trade  
                    Started by funk10101, Today, 09:43 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post funk10101  
                    Started by pkefal, 04-11-2024, 07:39 AM
                    11 responses
                    37 views
                    0 likes
                    Last Post jeronymite  
                    Started by bill2023, Yesterday, 08:51 AM
                    8 responses
                    45 views
                    0 likes
                    Last Post bill2023  
                    Started by yertle, Today, 08:38 AM
                    6 responses
                    26 views
                    0 likes
                    Last Post ryjoga
                    by ryjoga
                     
                    Working...
                    X