Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple StrategyPlot()

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

    #16
    ATI,

    I was doing as you were. Namely adding the timeframes/instruments, then the StrategyPlot dilio, then assigning values and it was plotting great. But then I overlayed the real indicator on top of my plotted value via the StrategyPlot, and set my StrategyPlot'd value to the same time frame as the base time frame and I found that my values were one full bar off. So something is out of sync.

    Just when I think I cracked the case, there seems to be another layer to address, lol.

    So I would try taking your plotted value and comparing it against the default time frame, and see if there is a discrepancy.

    I'm going to dig into this and get it resolved today. Being 1 full bar off on a 10m chart is critical!


    Thanks,

    r2kTrader

    Originally posted by ATI user View Post
    Josh

    I assume you only need to sync if you are trying to plot the added series from your strategy?

    Please confirm

    I add several timeframes to my cs and have never synced...just use the values for calcs...is this possibly causing problems/errors I do not know about?

    thanks

    Comment


      #17
      Josh,

      Could you elaborate on this?

      I'm really confused now. I have the same concerns as ATI.

      1. I have added a timeframe of 10m to my strategy.

      2. I have used the strategyPlot to plot the value of a plot value from an indicator that is using the 10m added timeframe as per 1.

      3. I then set my chart to the same time frame that I added, so I have my added BarSeries and my primary BarSeries the chart is set to. So both Primary and Added BarSeries are set to 10m.

      4. I then added the indicator to my chart in the native form and overlayed it on top of my Strategy plot to see if the values lined up. Their are near perfect except the Primary value based off the native indicator is plotting the value 1 bar ahead of the second bar array.

      Any help would be appreciated.


      r2kTrader

      Originally posted by NinjaTrader_Josh View Post
      ATI user,

      You only need to sync DataSeries if you want the series to hold continuous values of your secondary bar series.


      stefy,

      As discussed, StrategyPlot comes with its limitations. What is shown in the reference sample is what it can do and that is it. I cannot assist you further since it is an as-is solution. NT7 will provide multi-series charting.

      Comment


        #18
        Not sure what you mean. Syncing DataSeries has nothing to do with using StrategyPlot per se. It may only be relevant if you are using DataSeries objects to store some calculations before using StrategyPlot.

        Note: In NinjaTrader 8 It is no longer needed to use an indicator to sync a secondary series. This can be done directly from the Series<T> (https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?seriest.htm) constructor. This post is left for historical purposes. Series objects are useful for
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          Josh,

          This is my point. I am really having trouble wrapping my brain around when a DataSeries is necessary. When do I need to sync data?

          I'm really struggling with DataSeries and how they related to their respective Interfaces. I read all the support guides, etc. and stared at the samples for hours and have been scrubbing my 10 C# book from the local library and reading C# station. I am trying to mentally correlate C# with NT's approach. While the help guide is useful, I can't seem to get a full picture.

          I would appreciate any help.

          Originally posted by NinjaTrader_Josh View Post
          Not sure what you mean. Syncing DataSeries has nothing to do with using StrategyPlot per se. It may only be relevant if you are using DataSeries objects to store some calculations before using StrategyPlot.

          http://www.ninjatrader-support2.com/...ead.php?t=3572

          Comment


            #20
            r2kTrader,

            You only need to sync a DataSeries to a secondary data stream if the DataSeries you have is based off of the secondary data stream.

            DataSeries objects just store values for each bar you have on the chart. Let's say you have 100 bars on the primary and 50 bars on the secondary. Normally the DataSeries will be synced to the primary so your DataSeries will have 100 index slots. Each one corresponding to a bar. It works exactly the same as something like Close[0] works. Close[0] is the latest bar. Close[1] is the previous bar. myDataSeries[0] is the current bar. myDataSeries[1] is the previous bar.

            Now if you had a multi-time frame strategy and you had a DataSeries that was storing calculations for a secondary time frame you cannot have it synced to the primary because now referencing myDataSeries[1] would not necessarily be the prior value of the DataSeries based on the secondary time frame. Your myDataSeries has 100 index slots while the secondary time frame only has 50. This can be a problem with receiving null values and such. Instead, you can sync the DataSeries to the secondary time frame. That will make it have 50 index slots, the same as the secondary time frame.
            Josh P.NinjaTrader Customer Service

            Comment


              #21
              Josh,

              Ok, that is making sense. But why not just use BarsArray? If I can get this connected, I think the world will open up.

              I am studying interfaces and classes and constructors. Correlating C# with Ninja is slowly unfolding. If I can bridge them together then it will really accelerate things.


              Thanks,

              Comment


                #22
                How would you use BarsArray? To do what? BarsArray only tells you which bars series to run an indicator on.

                SMA(BarsArray[1], 20)[0] <-- I want to run the SMA on my secondary bars series. It has nothing to do with syncing a DataSeries to a secondary bars series.
                Josh P.NinjaTrader Customer Service

                Comment


                  #23
                  Originally posted by NinjaTrader_Josh View Post
                  How would you use BarsArray? To do what? BarsArray only tells you which bars series to run an indicator on.

                  SMA(BarsArray[1], 20)[0] <-- I want to run the SMA on my secondary bars series. It has nothing to do with syncing a DataSeries to a secondary bars series.
                  While this is obvious to you, it is not to me. Once I get it, it will click and I will be on my way.

                  Using your example above, I am using the BarsArray[1] to reference a secondary bar series. I understand that. Why would I need to light up a DataSeries? Why would I need to Sync a DataSeries?

                  Do I use a DataSeries because a BarsArray is only for holding the bar values of OHLC or whatever. Do I use a DataSeries to store values that are bound/linked/associated (pick term, don't mean to offend any programmers with my lack of vocabulary, lol) with the individual bars in the BarsArray?

                  For Example, and I won't try to code this on the fly. But I have a 2 data series. 1 is a 5m, and 1 is a 2m, both are on same instrument.

                  Do I light up or make a new DataSeries if say I want to hold the difference between the high/low for each bar in BarsArray[1]?

                  And if I am on the right track, at what point do I need to be sure I sync a DataSeries, could you slap a few more example recipes up? It can be psuedo, I just want to get this worked out in my brain. Then I can circle back to C# manuals and get the formal side and not take your time for that. Rather I want to understand how NT uses C# as it relates to the real world. I can get the syntax, etc. from homework and a cup of coffee and I don't expect you to teach me C#. I just want you to know that I am struggling with the relationship as it relates to the NT pardigms. Granted, it would be much easy to grasp if I had a stronger C# understanding, but both will much come together.

                  Thank you,

                  Comment


                    #24
                    r2kTrader,

                    DataSeries store any values you want. You sync a DataSeries to whichever bars series you are basing the values off of. BarsArray only references the different bars series. It does not store any OHLC values. All it does is reference which bar series to use. If you want to get OHLC of a secondary bars series you need to use Closes[1][0] etc.

                    If you have 2 DataSeries, one for 5min and one for 2min you need to sync the second one to the 2min. The first one will be synced to the 5min through default procedures.

                    If you want to store some secondary bars series calculations then you need to sync that DataSeries to the secondary bars. If you need some guideline as to when to sync to a secondary bars series, just sync it whenever you are storing values calculated from a secondary bars series.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #25
                      Josh,

                      Ok. I put together a dummy test to try to understand what I am doing. See attached.

                      Anyway, this is part of why I am confused. I am able to produce the same result in my output window with the following lines:

                      Print("test1 secondarySeries " + SecondarySeries.Indicator.Volume.ToString());

                      Print("test1 BarsArray " + Volume[0].ToString());
                      Now provided they are both under if (BarsInProgress == 1), they of course produce the same result.

                      So here is what I am wondering, why would I use a DataSeries? Would it be so I could get prior bars within the DataSeries for a given BarsArray?

                      I am really sorry for this, but I am just not understanding why I need a DataSeries. I am right brained, so if you could give an example of something you couldn't do with BarsArray, but could do with DataSeries (as it relates to the real world in a common situation that an average person would run into), then it would help.

                      I am as embaressed as you may be frustrated, so please show mercy on the ignorant

                      [UPDATE]
                      Do I need to setup a DataSeries and Sync it so I can automatically store values based on indicators/calculations or whatever and put those value in the DataSeries Container to pull on later? Whereas I if I just directly loaded it in a loop of somekind on every bar update I would have to build a class / array manually and do all that? In other words, is a DataSeries just a convenient way to store information that is related to a given bar? And further to that notion, if I sync it with a specific barsarray, then it will be stored in an index that is specific to that given bar for that bar array?

                      I think the fog is lifting, I'm just 100% why I need a DataSeries. I think I might be overcomplicating something that is very simple. Wouldn't be the first time ;-)

                      Thank you in advance,



                      r2kTrader
                      Attached Files
                      Last edited by r2kTrader; 03-03-2009, 08:06 PM.

                      Comment


                        #26
                        Originally posted by NinjaTrader_Josh View Post
                        If you have 2 DataSeries, one for 5min and one for 2min you need to sync the second one to the 2min. The first one will be synced to the 5min through default procedures.

                        If you want to store some secondary bars series calculations then you need to sync that DataSeries to the secondary bars. If you need some guideline as to when to sync to a secondary bars series, just sync it whenever you are storing values calculated from a secondary bars series.
                        Josh

                        I have not had a sync related error since I joined this thread. After catching up on the reading here it occurs to me that this is because I do not need to sync anything since I am not plotting anything, except the primary series data, and never reference outside of the current series in progress. Please confirm.

                        My strat adds 3 additional barseries to a 60 sec chart....180 sec...15 sec ...5 sec. I keep track by BarsInProgress which series I am in and set flags based on conditions during the respective series. Then from series 0 (the primary 60 sec chart) if a condition occurs, including using the flags from the other series, I enter/exit etc. At no time do I actually reference, for instance, series 2 while in series 0....which is what I believe you are saying is the reason to sync in the first place....correct?

                        so when you replied "ATI user,You only need to sync DataSeries if you want the series to hold continuous values of your secondary bar series.", it seems to me that I am not using continuous values right? I am avoiding the issue by staying within the series in my code and setting flags I can access from other series. Make sense? ...or am I still missing the point? Thanks.
                        Last edited by ATI user; 03-03-2009, 09:42 PM.

                        Comment


                          #27
                          Originally posted by r2kTrader View Post
                          So here is what I am wondering, why would I use a DataSeries? Would it be so I could get prior bars within the DataSeries for a given BarsArray?

                          I am really sorry for this, but I am just not understanding why I need a DataSeries. I am right brained, so if you could give an example of something you couldn't do with BarsArray, but could do with DataSeries


                          Thank you in advance,



                          r2kTrader
                          r2kTrader:

                          let's say you want some special calculations on each bar, for example
                          double myvalue = (close[1] + close[0] + open[0] + high[1])/4;
                          And now you want SMA of the last 14 myvalues?
                          So you declare dataseries to store those values for each bar:
                          MyDataseries.Set (myValue);
                          double Myothervalue = SMA(MyDataSeries,14)[0];

                          Try to do it without DataSeries, just with BarsArray...

                          Comment


                            #28
                            You don't know??

                            Originally posted by NinjaTrader_Josh View Post
                            Not sure what you mean. Syncing DataSeries has nothing to do with using StrategyPlot per se. It may only be relevant if you are using DataSeries objects to store some calculations before using StrategyPlot.

                            http://www.ninjatrader-support2.com/...ead.php?t=3572
                            You don't know what he's complaining about, Josh? I brought this issue up several weeks ago and you basically told me that this is broken due to the limitations of StrategyPlot.

                            Comment


                              #29
                              molecool,

                              Your issue is not his issue. His issue is he is trying to understand when one would want to sync a DataSeries and when one would want to use BarsArrays. That is what I understand from his questions and that is what I am trying to answer.

                              As far as a DataSeries working on StrategyPlot() the comment still stands. StrategyPlot() is provided as-is and any limitations you come across are what they are. NinjaScript Strategies were never designed to be used for plotting. Especially not for multi-series plotting. StrategyPlot() is an interim workaround till NT7 which will provide multi-series charting and allow for such plotting through indicators.
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #30
                                Originally posted by NinjaTrader_Josh View Post
                                molecool,

                                Your issue is not his issue. His issue is he is trying to understand when one would want to sync a DataSeries and when one would want to use BarsArrays. That is what I understand from his questions and that is what I am trying to answer.

                                As far as a DataSeries working on StrategyPlot() the comment still stands. StrategyPlot() is provided as-is and any limitations you come across are what they are. NinjaScript Strategies were never designed to be used for plotting. Especially not for multi-series plotting. StrategyPlot() is an interim workaround till NT7 which will provide multi-series charting and allow for such plotting through indicators.
                                Okay, I get it - his problem is that BarsArray doesn't implement the interface needed to support an SMA for example. Alright - sorry I jumped on you like that - I'll behave now.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                648 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                369 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                108 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                572 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                574 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X