Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sync Multiple Time Frames

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

    Sync Multiple Time Frames

    What is the proper way to synchronize multiple time frames in a strategy and return the current value of additional time series?

    I have a strategy using cumulative delta which requires a secondary 1 tick time frame and I have an additional 3 minute time frame...

    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    AddDataSeries(Data.BarsPeriodType.Minute, 3);
    }

    I need to synchronize them. Part of the logic is the current close is higher than the open of the 3 minute bar. (for longs)

    (Closes[2][0] > Opens[2][0])

    It looks like the values of the previous 3 minute candles are being returned not the current.

    I see under help guide cumulative delta instructions on syncing the 1 tick time frame.

    else if (BarsInProgress == 1)

    {

    // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync

    cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);

    }




    #2
    Hello sdauteuil,

    From the description that sounds correct, when using 0 bars ago that would return the last closed bars value. Depending on what series called the Closes[2][0] that would return the last closed 3 minute bar at that time in processing. Only if you are in Realtime and using OnEachTick calculation would the Closes[2][0] represent that series last price.

    The other logic you have shown is needed specifically for the CumulativeDelta indicator because that is required for it to work, that is not something you would need when adding other series or using other indicators.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      In real time is it possible to have the primary bar / time frame operate under OnBarUpdate()
      and have the additional time frame (3 minute in this case) operate OnEachTick.

      Basically if I am using OnBarUpdate can I access the current / real time value of the other time series?

      Comment


        #4
        Also I currently do not have the code to sync the 1 tick time frame for cumulative delta.

        Should I add this (code below) under State == State.DataLoaded?


        else if (BarsInProgress == 1)

        {

        // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync

        cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);

        }

        Comment


          #5
          Hello sdauteuil,

          In real time is it possible to have the primary bar / time frame operate under OnBarUpdate()
          and have the additional time frame (3 minute in this case) operate OnEachTick.

          Basically if I am using OnBarUpdate can I access the current / real time value of the other time series?
          No however when using OnEachTick you could simulate that by using IsFirstTickOfBar as long as you are using a BarsType which supports that. Basically all bars types except renko.
          https://ninjatrader.com/support/help...FirstTickOfBar

          Also I currently do not have the code to sync the 1 tick time frame for cumulative delta.

          Should I add this (code below) under State == State.DataLoaded?
          Yes but that would go in OnBarUpdate just like the sample shows, that is required for this indicator.

          Please let me know if I may be of additional assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Which is the proper use of if and else if in this instance? Use If and else if OR Use 2 if statements

            protected override void OnBarUpdate()
            {
            if (BarsInProgress == 1)
            cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);

            if (BarsInProgress != 0)
            return;

            if ((CurrentBars[0] < 20)
            || (CurrentBars[1] < 20)
            || (CurrentBars[2] < 20))
            return;

            // Rest of Code

            OR

            protected override void OnBarUpdate()
            {
            if (BarsInProgress == 1)
            cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);

            else if (BarsInProgress != 0)
            return;

            if ((CurrentBars[0] < 20)
            || (CurrentBars[1] < 20)
            || (CurrentBars[2] < 20))
            return;

            // Rest of Code

            Comment


              #7
              Hello sdauteuil, thanks for your reply.

              We use the ELSE clause when we want something to happen if the previous condition was explicitly false. The ELSE part will only be evaluated if the above IF is false. In this case you would want to use
              if (BarsInProgress == 1)
              cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);

              if (BarsInProgress != 0)
              return;

              Please let me know if I may provide any further information.
              Chris L.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Johnny, Today, 11:55 AM
              0 responses
              13 views
              0 likes
              Last Post Johnny
              by Johnny
               
              Started by MGHORBEL, Today, 10:48 AM
              0 responses
              17 views
              0 likes
              Last Post MGHORBEL  
              Started by daven, Today, 09:49 AM
              7 responses
              27 views
              0 likes
              Last Post daven
              by daven
               
              Started by omermirza, 01-15-2021, 01:15 PM
              14 responses
              123 views
              0 likes
              Last Post omermirza  
              Started by Island_Boy_Trading, Today, 07:39 AM
              2 responses
              18 views
              0 likes
              Last Post Island_Boy_Trading  
              Working...
              X