Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting custom dataseries during backtest

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

    Plotting custom dataseries during backtest

    Hello,

    I need to plot calculated values on a chart, and StrategyPlot may be exactly what i need. Unfortunately it does not work during backtest (a rather strange limitation). Any solution to this issue?

    #2
    Hello,

    Thanks for the forum post.

    This is the case unfortuantely, the only 2 workaround I can think of are switching to using a DrawObject to plot what you needed. your other option is to seperate out your logic into another indicator. Then Add(Indicator); in the strategy, you can do this as long as the strategyplot does not count on strategy data points. If what you need to plot can be calculated off the OHLC values on the bars than this is an option as well.

    -Brett

    Comment


      #3
      Well, I figured out the DrawObject method, but a) it seems slow b) i can draw on the main chart only (and i want also use the indicator chart).
      As far as the Add(Indicator); method is concerned, I'm not sure it'll work, since indicator's onBarUpdate() only has access to the "primary dataset". Am I right?
      I'd like to draw custom indicators based on secondary datasets.

      Comment


        #4
        If the secondary data sets are another bar objects then in the indicator this will work because you can build indicators that are Multi Time Frame. You can add in the secondary Series into the indicator.

        -Brett

        Comment


          #5
          How do I add a secondary time series to the indicator? Any example would be helpful.

          Comment


            #6
            Hi Gena72,

            There is a sample available in all installations. Click Tools menu > Edit NinjaScript > Strategy > SampleMultiTimeFrame. Documentation for this is available here:
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Well, there's a good explanation of how to calculate indicators on secondary data series (something like SMA(BarsArray[1], 1)).
              However, i still have no idea how to plot this indicator.
              Attempting to "Add(SMA(BarsArray[1], 1));" in "Initialize()" does not work as i get:
              'BarsArray' property can't be accessed from within 'Initialize' method

              Comment


                #8
                Great, you got the first part then on adding the series. You can access secondary series values with items like BarsArray[1], Closes[1], Highs[1], etc.

                Plots can be set on these secondary series.

                Value.Set(ATR(BarsArray[1], 5)[0]);
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  This does not seem to work in a backtest mode, as i stated earlier:
                  1. In OnBarUpdate() of my custom indicator, BarsArray only has 1 main dataseries (BarsArray.Length = 1). For some reason the secondary data series is excluded
                  2. In OnBarUpdate() of the strategy itself BarsArray holds all dataseries (BarsArray.Length = 2), but CustomInd(0).Value.Set(SMA(BarsArray[1],20)[0]); does nothing as the indicator is not being plotted

                  Comment


                    #10
                    All the multiseries logic is in the indicator, and the strategy just adds it. I've attached a couple scripts here if you want to see how it can work.

                    To import:

                    1. From the Control Center window select the menu File > Utilities > Import NinjaScript to open the Import NinjaScript dialog window
                    2. Select the file you want to import
                    3. Press the "Open" button
                    Attached Files
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Ok, it works now. I was supposed to add second dataseries inside the indicator and not inside the strategy. I think this should make it into examples section, as the documentation is not very clear on this subject.

                      Thank you!

                      Comment


                        #12
                        OK, glad that worked for you and sorry for any confusion regarding the technique. I will forward your comments to our documentation team. This has been assigned tracking ID # 1449. Thank you for the feedback.
                        Last edited by NinjaTrader_RyanM1; 01-24-2012, 02:39 PM.
                        Ryan M.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by junkone, Today, 11:37 AM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by frankthearm, Yesterday, 09:08 AM
                        11 responses
                        42 views
                        0 likes
                        Last Post frankthearm  
                        Started by quantismo, 04-17-2024, 05:13 PM
                        5 responses
                        35 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by proptrade13, Today, 11:06 AM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Started by love2code2trade, 04-17-2024, 01:45 PM
                        4 responses
                        35 views
                        0 likes
                        Last Post love2code2trade  
                        Working...
                        X