Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-time frame clarification

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

    Multi-time frame clarification

    In the help file the following appears:

    DataSeries objects can be used on supplementary series in a multi-time frame and instrument strategy. Please see our support forum NinjaScript reference samples section for further information.

    Can you point me to where this is discussed? I am having issues with setting a dataseries passed by ref to a UserDefinedMethod.

    Once there have been enough bars to start calling the method, I set the value the first time through with a specific calculation and after that a more general one - the equivalent of an EMA calculation where I provide the first value and from that point on it is a normal EMA calculation.

    I want to do this in the UserDefinedMethod to push as much code into the method as possible and therefore encapsulate the process to the extent possible.

    I am only calling the method once there are enough bars and thought I could use
    if (ds1.ContainsValue(1) == false) to see if a value had been set yet and if not, set ds1[0]. Then the next test would fail and I could switch to the other calculation.

    It would seem that once I have set a value in the data series that test should fail from then on but although normally it does, at times it does not. What could cause this (a missing bar)?

    Thanks in advance
    Scott
    Last edited by ScottB; 03-16-2011, 11:07 PM.

    #2
    Hi Scott, the sample mentioned was this one - http://www.ninjatrader.com/support/f...ead.php?t=3572 It deals with synching a custom DataSeries to an Add()ed series / barsobject.

    Do you 'lose' the value only in a MultiSeries script context?

    Comment


      #3
      Bertrand, yes it is only with the secondary data series (eventually there will be several). It was primarily in historical data so I let it run overnight and it didn't happen again.

      These are production systems so I have to be able to explain every nuance of behavior that is why I dig into these things so deeply.

      I reviewed the sample and I was not syncing the secondary series in the way it does. I will change my code to reflect this approach. For now you can assume that will fix it.

      I saw in another post a reference to the Pivots code that comes standard, are there any others like that you would recommend looking at? Knowing NinjaTrader better is always helpful.

      Will you by chance be at the developers conference in April?

      Thanks for your great help (as always).

      Best Regards,
      Scott

      Comment


        #4
        You're welcome Scott - valuable code sample would include our PowerVolume indicators, Pivots and also the CustomPlotSample - please note though that some (unsupported / undocumented) method are used here. I will likely not be at this conference - hope you will have an enjoyable time there.

        Comment


          #5
          Bertrand, after starting to make the change to my code, I realized I need one more clarification of the sample where you are instantiating a new data series in OnBarUpdate.

          I am trying to pass OHLC of the secondary series to a method in UserDefinedMethods. Because I was told there is no way to pass only the BarsArray and then get OHCL in the method, I have to pass the actual individual data series i.e. myOpen, myHigh...

          Therefore I am not certain how I would do the new myOpen = new DataSeries(myMethod(parameters... when I need that for myOpen, myClose, etc

          Also, from the example (it uses SMA as the indicator), it appears you don't make any additional calls to the indicator itself (SMA), the secondarySeries.Set will take care of things (I assume because it is sync'd).

          I need to pass by ref because other values I pass in (like in a HeikenAshi requires OHLC plus the data series of prior calculations) depend on their prior calculations so I have to be able to instantiate those as well and have them sync'd as a unit.

          One way around all of this would be to pass in the index of the bars array for the secondary series and let the method figure it out. The glitch with that is the method would have to have its own call to call storage and it would have to be unique to each secondary data series.

          For example, if I am doing this on a 15 minute chart with 60 minute and 240 minute bars as secondary data series, I could pass in a 2 for the index of the 240 minute BarsArray but the method would have to be able to store internal values between calls much like a class level variable.

          That would also mean it would have to be able to instantiate a data series itself which would be sync'd to the 240 minute bar. I would then go through the entire process again for the 60 minute data series and those values would have to be separate from the 240 variables.

          Because I am doing a new, I assume the UserDefinedMethods method is going to be unique to each instantiation and the reference will be held in the variable in the calling method.

          I know this sounds complicated but this is a routine we find ourselves using over and over and it has been decided I am the lucky guy who gets to turn this into a common routine.

          If none of this works, I will just write an external DLL and do it that way.

          Hopefully, you can decipher all this. Just saw your reply (it crossed with this one); thanks on many levels.

          Best Regards,
          Scott
          Last edited by ScottB; 03-17-2011, 07:54 AM.

          Comment


            #6
            Bertrand,

            I cheated and found a way around the problem; maybe you can help me refine the solution.

            I created a dummy indicator called SyncDataSeries and passed it the BarsArray of the dataseries I want to sync with; that gives me one dataseries element for each bar in that BarsArray.

            myDataSeries1 = new DataSeries(SyncDataSeries(BarsArray[1]);

            Now I can simply pass in the index of the dataseries and the variable to the method

            myUserDefinedMethod(1, myDataSeries);

            and all is good.

            There has to be a better way to do this but this is the best I could think of. The main issue would be a better way to sync a dataseries variable with a BarsArray. My guess is, you will laugh (to yourself) and say something like - why don't you just ....

            Best Regards,
            Scott

            Comment


              #7
              Hi Scott, I think that's a 'valid' cheat, as an indicator need to be used for achieving the sync - I would currently not be aware of another way but will keep brainstorming...

              Comment


                #8
                Bertrand my good man, if it is good enough for you, it is certainly good enough for me. And best of all it works!

                Best Regards,
                Scott

                Comment


                  #9
                  Details

                  Originally posted by ScottB View Post
                  Bertrand,

                  I cheated and found a way around the problem; maybe you can help me refine the solution.

                  I created a dummy indicator called SyncDataSeries and passed it the BarsArray of the dataseries I want to sync with; that gives me one dataseries element for each bar in that BarsArray.

                  myDataSeries1 = new DataSeries(SyncDataSeries(BarsArray[1]);

                  Now I can simply pass in the index of the dataseries and the variable to the method

                  myUserDefinedMethod(1, myDataSeries);

                  and all is good.

                  There has to be a better way to do this but this is the best I could think of. The main issue would be a better way to sync a dataseries variable with a BarsArray. My guess is, you will laugh (to yourself) and say something like - why don't you just ....

                  Best Regards,
                  Scott


                  Could you please explain in more details how this cheat is done and used in a strategy?

                  Many thanks,
                  bkool

                  Comment


                    #10
                    bkool, this was more a technical issue and doesn't have a use per se in a strategy unless you are syncing multiple data series. The idea is to make certain all your data series are sycnronized in a way that gives you a separate data series for each element in the bars array. I wrote an indicator that doesn't do anything except provide a placeholder for that purpose.

                    The examples Bertrand gave are a very good place to start. Once you have gone through those please feel free to ask if you need further clarification.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    605 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    351 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    105 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    560 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    561 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X