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

mtf strategy + no primary serie condition = all plots should sync

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

    mtf strategy + no primary serie condition = all plots should sync

    hello All,

    In a strategy with all conditions based on secondary series of the same primary instrument - with the purpose of being watchable or tradable on any time frame in a chart window - markers do not match between charts.
    after checking again that all conditions and actions are on secondary series, markers still do not match.

    Can anyone tell us how this can be ?

    #2
    Hi Amedeus,
    Can you provide a little more detail what the time frame of your primary and secondary series is?
    Do you synch your additional data series to the primary series?
    Can you show us a basic example of where and how markers don't match?
    NT-Roland

    Comment


      #3
      hey NT-Roland, thank you

      first : the arrows don't match because they are on the primary series. (the only action on the primary)

      the circled markers in the 144 frame do not show on the 987, yet the orders are on the secondary series of 300.

      the order was set on the secondary, how come it does not show on the primary ?
      Attached Files

      Comment


        #4
        Hi Amedeus,
        Do you get the same list of trades for your 987 primary / 300 secondary setup as for the others?
        Are only markers missing or also trades?
        NT-Roland

        Comment


          #5
          hi Roland, thanks,
          The number of trades in the analyzer is about 2/5. less with the bigger scale too.
          I just checked the associations of the parameters to their secondary series again and it is all on secondary...

          Comment


            #6
            Hi Amedeus,
            This is exactly what I expected.
            You use a primary series 987, which is not a multiple of the secondary 300, and you likely use Calculate.OnBarClose.
            Have a look at the multi-time-frame section in the Help guide, most importantly, the processing sequence.


            Chances are high that the signals from the secondary time frame are not yet valid or not valid anymore at the time the primary series is processed.
            NT-Roland

            Comment


              #7
              Hi Roland, thank you,
              I think you are spot on, especially because i used parameters from 4 frames, but :
              I just made all secondary series multiples of themselves, yet the number of trades still did not match. Certainly due to the OnBarClose calculation.

              Because I try to dodge the OnEachTick calculation
              - wich still seems possible for what i am trying to accomplish - even if OnEachTick apparently would solve the situation and any trigger would be processed on each tick regardless -
              I did change (or remove, for the purpose of the operation) all parameters to one and only secondary series : very much unexpectedly the numbers of trades of the 900 and 300 analyses doesnt match... is it not were it should have ?

              Comment


                #8
                Hi Amedeus,
                Using multiples eliminates the issue that the primary and secondary series bars almost always form at completely different times, but it does not guarantee that all your secondary (300) bars start or/and close in synch with your primary (900) bars. For every bar of 900, you (still) have 3 bars of 300.
                The 1st 300 bar, shares the start, but not the end with the 900 bar.
                The 2nd 300 bar is "inside" the 900 bar. It shares neither start nor end.
                The 3rd 300 bar shares the end but not the start with the 900 bar.
                And the primary series is still processed before the secondary.
                Do you run the different sections of your code depending on "BarsInProgress"?
                if (BarsInProgress == 0)
                { Primary Bar }
                if (BarsInProgress == 1)
                { Secondary Bar }
                ...
                You can submit orders to different bars objects. You can even enter on one time frame and exit on another.

                NT-Roland

                Comment


                  #9
                  Hello Amedeus,

                  The orders are based on time.

                  These will show on the primary bar of the same instrument, within the bar that covers the time stamps of the orders.

                  To confirm, the strategy is only applied to one chart, and the other chart has no strategies applied to see all orders to the account, is this correct?

                  What is the time and date of a specific order you are seeing on different bars?
                  What is the time and date of the bar before and after that specific order on the chart with the strategy applied?
                  What is the time and date of the bar before and after that specific order on the chart without any strategies applied?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chelsea,

                    I'll will answer your quick questions 1st, before even figuring out what Roland meant with the BarsInProgress question and how it is relevant.

                    I do not confirm. The missing markers are not from the account.
                    They are from one strategy applied to multiple chart tabs in one window.
                    Do the time and dates of the bars still matter ?

                    Comment


                      #11
                      Hello Amedeus,

                      If the orders are not from the account and are from separate instances script instances, the logic of the script and the data can cause differences and how these are displayed will still matter.

                      However, instead of just having to check the order time stamp and the before and after bar timestamps, now you need to also check the order stamps are the same from the logic in every instance.

                      Historical vs real-time would also come into play with 1-tick intra-bar granularity and TickReplay if this is historical data.


                      The orders would have to have been submitted at the exact same time, and then these would display on the bar the order is within the timestamp of.


                      Below is a link to a forum post on using prints to understand behavior. The prints would print the time of the bar and all


                      Also, below is a link to a forum post that has an example script that writes to text file as this can be too much data for the output window.
                      Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        hey C and R, thank you both

                        Chelsea, the screencast link requires to have flash, we cannot download it anymore... what can we do about that ? the tutos titles looked great.

                        I have attached the detail of the prints of the entry actions for the yellow triangle trades which looked to be good divergence specimen, as well as a better overview and detailed views of the chart they are from. (the same example as in post 3), with the time axis so we can really have the best visual of this.
                        The chart sample is with the strategy where there is now only one added secondary series of 300 to make it simpler. We are trying to reduce the impact of the IntraBar missing events when the 300 secondary series strategy is ran on a primary 900, to see if an acceptable resolution is possible on this scale.

                        I tried to enter the attached NSEditor IntraBarBacktest from formula in the strategy builder but could not find how once selecting CurrentBar. Is this method doable only via hand coding ? is there no BarsRequiredToTrade parameter in the builder ? this question also goes for the SampleMultiTimaFrame Startegy too.
                        Is there no choice but to pass to the next level and copy paste from the >ViewCode to the NSEditor like shown in the NSEditor401 ? and essentially work from a "HeadQuarter" actual script in wich pieces of scripts from the builder are copied and pasted? wich requires much greater accuracy and focus.

                        Also, I tried the TickReplay option over a 2 week backtest : it is too much calculation for what we are trying. and the trades numbers of 300 and 900 analyses dont show a significant improvement in the divergence...

                        Attached Files

                        Comment


                          #13
                          Hi Amedeus,
                          Are you asking for a Multi-TimeFrame script in the Strategy Builder?
                          I'm more than happy to be corrected, but think, the StrategyBuilder is limited to one OnBarUpdate(), linked to the primary series.

                          If you prefer to stick to the StrategyBuilder, I recommend to pick the smallest series as primary (drum beat). Your indicators can still be calculated on additional, larger series, if and to the extent desired.

                          By contrast, if you use NinjaScript, you can combine a primary series of 900 ticks for something (even if only for the chart) and run your trade relevant code logic in OnBarUpdate of the secondary series (300 ticks) or additional series.

                          In OnBarUpdate(), make sure to
                          1) deactivate the default "if (BarsInProgress != 0) return";
                          2) check that you enough bars of all series you added to the strategy.
                          if (CurrentBars[0] < 1 || CurrentBars[1] < 1 || ... CurrentBars[n] < 1)
                          return;

                          Then execute your code in OnBarUpdate of the respective series.

                          if (BarsInProgress == 0)
                          { Say hello to the world }

                          if (BarsInProgress == 1)
                          { Really do something }

                          NT-Roland

                          Comment


                            #14
                            Hey Roland and Chelsea,

                            I don't know what's the best working NS configuration for me yet. I guess the back and forth between both builder and NSEditor will at some point be inevitable wether it is because of the set pile getting high or the little details like this... so thank you for the real good tips and exercice.
                            "the Ultimate Ninjascript Working Organization Setup" might be an upcoming topic on this forum.

                            Anyway here below is the result of the Unlocked last script with the BarsInProgress method just above. It is a lot better visually.
                            We can still see a some smaller divergeance in the numbers of trade from the analyzer, and on the chart like in the 2nd figure.

                            Chelsea, I was not able to find exactly wich bar is wich in the output because there are a few of them with the same timing in the output but not on the chart.
                            The reloads for the output prints from each strategy was done separately with TraceOrder enabled, and in the txt file are a sample of each outputs where the time seems to make sense.
                            Attached Files
                            Last edited by Amedeus; 05-24-2021, 04:44 PM.

                            Comment


                              #15
                              Hi Amedeus,
                              Congrats. You made a big step in the right direction. This looks much better now.
                              I don't really understand the 2nd picture. You can, of course, have two trades within the same 900 tick bar, if the logic is run against the 300 tick bar, but I would then expect the same trade on the 300 tick bar chart. Do you use "Break at EoD" in both scenarios?
                              NT-Roland

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by trilliantrader, Today, 03:01 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by geddyisodin, Today, 05:20 AM
                              6 responses
                              34 views
                              0 likes
                              Last Post geddyisodin  
                              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
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X