Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Possible Discovery of an Alternate Universe

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

    Possible Discovery of an Alternate Universe

    Hi,

    This is a continuation of a thread that I think got closed by support because I said I could figure it out from what you had already told me; boy was I wrong.

    I have the following code in a calling strategy and a UserDefinedMethod. This involves the primary instrument 1 minute 6E and a secondary 5 minute 6E.

    I have tried this with the DataSeries variable in the main strategy as well as in the UserDefinedMethod and they both produce the same results.

    In the main strategy

    In Initialize
    Add(PeriodType.Minute, 5);

    In OnBarUpdate
    if
    (BarsInProgress == 1 && FirstTickOfBar == true)
    {
    // call the UserDefinedMethod
    ...

    In the UserDefinedMethod

    if
    (test == null)
    test = new DataSeries(this);


    test.Set(1, Opens[1][1]);
    Print("Open " + test[1].ToString() + " " + Times[1][1].ToString() + " " + test[2].ToString() + " " + Times[1][2].ToString());

    Since this is called on the first tick to the secondary data, I use Opens[1][1] to get the open of the last completed bar in the secondary series.

    Here is my output and my argument for the discovery of an alternate universe

    The first numbers match the times but the second not only don't line up with the line before it, they aren't even in the right big figure. I have no idea what I am doing wrong but it is definitely something.

    Open 1.3633 9/29/2010 11:25:00 AM 1.3465 9/29/2010 11:20:00 AM
    Open 1.363 9/29/2010 11:30:00 AM 1.3466 9/29/2010 11:25:00 AM
    Open 1.363 9/29/2010 11:35:00 AM 1.3464 9/29/2010 11:30:00 AM
    Open 1.3621 9/29/2010 11:40:00 AM 1.3462 9/29/2010 11:35:00 AM
    Open 1.3619 9/29/2010 11:45:00 AM 1.346 9/29/2010 11:40:00 AM
    Open 1.3616 9/29/2010 11:50:00 AM 1.3458 9/29/2010 11:45:00 AM
    Open 1.3621 9/29/2010 11:55:00 AM 1.346 9/29/2010 11:50:00 AM
    Open 1.3627 9/29/2010 12:00:00 PM 1.3456 9/29/2010 11:55:00 AM
    Open 1.3627 9/29/2010 12:05:00 PM 1.3451 9/29/2010 12:00:00 PM
    Open 1.3635 9/29/2010 12:10:00 PM 1.3454 9/29/2010 12:05:00 PM
    Open 1.3635 9/29/2010 12:15:00 PM 1.3452 9/29/2010 12:10:00 PM
    Open 1.3635 9/29/2010 12:20:00 PM 1.3461 9/29/2010 12:15:00 PM
    Open 1.364 9/29/2010 12:25:00 PM 1.3453 9/29/2010 12:20:00 PM
    Open 1.3635 9/29/2010 12:30:00 PM 1.3449 9/29/2010 12:25:00 PM
    Open 1.3631 9/29/2010 12:35:00 PM 1.3452 9/29/2010 12:30:00 PM
    Open 1.3628 9/29/2010 12:40:00 PM 1.345 9/29/2010 12:35:00 PM

    Thanks
    Scott

    #2
    Scott,

    No problem.

    Can you please point out which specific line in the output is incorrect. As i'f I'm understanding the code correctly I dont understand anything wrong here in all the lines?

    Also, I laughed at your Discovery of an alternate universe

    I look forward to assisting you further.

    Comment


      #3
      Brett, thanks for getting back to me; I am glad that gave you a laugh. Every single line is wrong.

      The last one (at the bottom) prints the value I meant to sync up with the 12:40 pm bar and then the value with the 12:35 bar (on the same line). The numbers on the left are in fact, the opens as they appear on a chart.

      However, I would then expect the value in the last line for the 12:35 bar (1.3450) to be the same value as the line above that which prints the value for the 12:35 bar (1.3631). I have no idea where 1.345(0) came from, hence the thought on the alternate universe. It doesn't match anything, as I said, it isn't even in the same big figure.

      When I set test one place back test.Set(1,... I assume that since I do that every bar, the values should propogate backwards, test[1] is set (test[0] is never set because we don't have a completed bar at the point this is called (FirstTickOfBar), then next bar I set test[1] again which should make the former test[1] now test[2], etc.

      I think of this like a stack, put the first value in test[1] and then each time I do that on a new bar the value moves down 1 place in the stack. But under any circumstances, where on earth (or elsewhere) could those numbers be coming from. They are obviously from the 6E but do not match anything.

      I hope this give you something to go on. I have stripped this down to the code you see, there are no other places where this variable is set or even used.

      Thanks
      Scott

      Comment


        #4
        Hello,

        Heres probably your issue:

        DateSeries objects are always synced to the primary data series unless otherwise programmed. Please see this reference sample on how to do this.

        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


        Let me know if I can be of further assistance.

        Comment


          #5
          Brett, I have looked at this example in the past but it is synced to an indicator:
          secondarySeries = new DataSeries(SMA(BarsArray[1], 50)); how would I sync this to a secondary timeframe?

          I need this synced to the secondary price series so I have one value per bar in the secondary series as all calculations are done from the higher timeframe bars.

          I have the same calculations in an indicator that uses COBC = true but I need every tick for my trades so I can't have that setting for my strategy. If I could call the custom indicator and get the internal value it uses to decide how to paint the bar, that would work just fine.

          It seems the best approach is to understand what I am doing wrong with the code I have.

          Comment


            #6
            Hello,

            It is synced to the secondary time frame because you used this:

            BarsArray[1],

            The indicator is just d ummy value that gets replaced when you set it.

            You need to set this value in BIP 1. I dont see that you making any check for if Bars In Progress = 1

            then test.Set(1, Opens[1][1]);

            You would just replace this to Open[1] when making the Bars In Progress check.

            If you do not make the Bars In Progress check and use Opens instead this will be synced to the Primary data series and not the Secondary Data Series and would not give you the results your looking for I dont believe.

            Comment


              #7
              Brett, thanks for the reply. I am making the check on the calling side but even before you suggested it, I tried what you suggested, in fact, I even moved the code all into one strategy and am still getting the same results.

              I have moved to an IntSeries and that seems to work. It may be one of those little unsolved mysteries in life. When you say I would just replace Open[1] when making the BIP check, I am not sure what you mean; would you qualify that for me?

              Thanks

              Comment


                #8
                Hello,

                Glad your up and running.

                This means that you do not need to use the Opens array when in BIP. You only need Open[1] as when your are in BIP 1 you will using the Open price of 1 bar back of the BIP 1 instrument automatically.


                Let me know if I can be of further assistance.

                Comment


                  #9
                  Perfect, thanks Brett.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Haiasi, 04-25-2024, 06:53 PM
                  2 responses
                  17 views
                  0 likes
                  Last Post Massinisa  
                  Started by Creamers, Today, 05:32 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post Creamers  
                  Started by Segwin, 05-07-2018, 02:15 PM
                  12 responses
                  1,786 views
                  0 likes
                  Last Post Leafcutter  
                  Started by poplagelu, Today, 05:00 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post poplagelu  
                  Started by fx.practic, 10-15-2013, 12:53 AM
                  5 responses
                  5,407 views
                  0 likes
                  Last Post Bidder
                  by Bidder
                   
                  Working...
                  X