• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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
    BrettNinjaTrader Product Management

    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
        BrettNinjaTrader Product Management

        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:
            http://www.ninjatrader.com/support/h...nstruments.htm
            Ryan MNinjaTrader 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 MNinjaTrader 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 MNinjaTrader 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 MNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by StevenNelson, Today, 12:23 PM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_PatrickG  
                        Started by kokobeef, Today, 12:32 PM
                        2 responses
                        9 views
                        0 likes
                        Last Post kokobeef  
                        Started by Jackrpo, Today, 11:14 AM
                        2 responses
                        9 views
                        0 likes
                        Last Post Jackrpo
                        by Jackrpo
                         
                        Started by DariusDeck, Yesterday, 04:22 PM
                        7 responses
                        49 views
                        0 likes
                        Last Post NinjaTrader_ChristopherJ  
                        Started by laszlonagy, Today, 09:28 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post laszlonagy  
                        Working...
                        X