Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Timeframes in Live

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

    Timeframes in Live

    Hi,

    First, my englisch is far from perfekt.

    I use in an indicator 2 additional Timeframes:
    Code:
    AddDataSeries(Data.BarsPeriodType.Second, 1);
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    The Chart is shown in Timeframe 1 Minute

    I need the TimeFrame second to calculate an EMA and the Timeframe Tick is used for Baktesting on Tickreplay.
    In Backtesting it would all be nice, but i have troubles on live.
    In the Method OnBarUpdate i wrote some Print-Statements to get the calling Timefrime:
    Code:
    Print(this.Name + " Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[BarsInProgress].Bars.GetTime(Closes[BarsInProgress].Count));
    Print(this.Name + " Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[0].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[0].Bars.GetTime(Closes[0].Count));
    Print(this.Name + " Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[1].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[1].Bars.GetTime(Closes[1].Count));
    Print(this.Name + " Closes[2].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[2].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[2].Bars.GetTime(Closes[2].Count));
    The Result in Backtesting: (this output is expected
    Code:
    _Labandowsky_Indicator Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Tick - 10.03.2021 04:44:35
    _Labandowsky_Indicator Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 04:45:00
    _Labandowsky_Indicator Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 04:44:36
    _Labandowsky_Indicator Closes[2].Bars.BarsPeriod.BarsPeriodTypeName: Tick - 10.03.2021 04:44:35
    The Result in Live:
    Code:
    _Labandowsky_Indicator Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 05:25:00
    _Labandowsky_Indicator Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - [U][B]10.03.2021 05:25:00[/B][/U]
    _Labandowsky_Indicator Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - [U][B]10.03.2021 04:55:42[/B][/U]
    _Labandowsky_Indicator Closes[2].Bars.BarsPeriod.BarsPeriodTypeName: Tick - 10.03.2021 04:55:47
    The OnBarUpdate is only called with Minute, per Tick, but only in Minute. But the greatest Problem is, the DataSeries for the 2 added Timeframes will not be updated.
    It is ok, OnBarUpdate is only called per Minute, its the Timeframe of the chart, but what can i do, to get a actual Dataseries for TimeFrame Second?

    #2
    Hello SpikeLGWG,

    Typically, CurrentBar or CurrentBars is used to the values from series, or the series themselves can be used.



    Try printing BarsArray[0].GetClose(CurrentBars[0]), or Closes[0][0].


    Each series will be updating OnBarUpdate() as the bar for that series updates. You can find which series is updating OnBarUpdate() by printing the value of BarsInProgress outside of any conditions.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello, thanks for your answer.

      used TimeFrames:
      Code:
      AddDataSeries(Data.BarsPeriodType.Second, 1);
      AddDataSeries(Data.BarsPeriodType.Tick, 1);
      this Code:
      Code:
      Print(this.Name + " Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[BarsInProgress].Bars.GetTime(Closes[BarsInProgress].Count) + " # BarsInProgress: " + BarsInProgress);
      produce this result:
      Code:
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:14:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:14:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:14:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:14:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:14:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:15:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:15:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:15:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:15:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:15:00 # BarsInProgress: 0
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:15:00 # BarsInProgress: 0
      this Code:
      Code:
      Print(this.Name + " Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[BarsInProgress].Bars.GetTime(Closes[BarsInProgress].Count) + " # BarsInProgress: " + BarsInProgress);
      Print(this.Name + " Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[0].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[0].Bars.GetTime(Closes[0].Count) + " # " + BarsArray[0].GetClose(CurrentBars[0]).ToString("N2"));
      Print(this.Name + " Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: " + Closes[1].Bars.BarsPeriod.BarsPeriodTypeName + " - " + Closes[1].Bars.GetTime(Closes[1].Count) + " # " + BarsArray[1].GetClose(CurrentBars[1]).ToString("N2"));
      produce this result:
      Code:
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 837,47
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 838,38
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 852,30
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 843,54
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 851,64
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 852,31
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 853,34
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 853,59
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 852,56
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:20:00 # 55 852,30
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:29 # 55 782,59
      This result says to me, on live is only the "BarsInProgress" called the OnBarUpdate, as you see, the "Second" timeframe get no Update.
      The Result on Backtesting:
      Code:
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 783,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # BarsInProgress: 1
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 783,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # BarsInProgress: 1
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 787,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Tick - 10.03.2021 22:17:23 # BarsInProgress: 2
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 787,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Tick - 10.03.2021 22:17:23 # BarsInProgress: 2
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 787,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 787,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # BarsInProgress: 1
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 787,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Tick - 10.03.2021 22:17:23 # BarsInProgress: 2
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 787,00
      MyEMA Closes[BarsInProgress].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # BarsInProgress: 0
      MyEMA Closes[0].Bars.BarsPeriod.BarsPeriodTypeName: Minute - 10.03.2021 22:18:00 # 55 787,00
      MyEMA Closes[1].Bars.BarsPeriod.BarsPeriodTypeName: Second - 10.03.2021 22:17:24 # 55 787,00
      the Timeframe from Second and Tick will call OnBarUpdate.

      is there only a Checkbox missing?

      Comment


        #4
        Hello SpikeLGWG,

        To export a NinjaTrader 8 test NinjaScript so this can be shared and imported by the recipient do the following:
        1. Click Tools -> Export -> NinjaScript...
        2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
        3. Click the 'Export' button
        4. Enter a unique name for the file in the value for 'File name:'
        5. Choose a save location -> click Save
        6. Click OK to clear the export location message
        By default your exported file will be in the following location:
        • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
        Below is a link to the help guide on Exporting NinjaScripts.
        http://ninjatrader.com/support/helpG...-us/export.htm


        With the output, I would likely expect that is historical data without TickReplay.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          i attached the indicator.

          In the Historical Backtesting i have tickreplay, this would work perfect, but in live the OnBarUpdate is only called by the chart Timeframe and öther Timefrimes are not updated.
          This can you see in the outputs.

          This is a strange behavior, maybe i did a wrong setting while installing NinjaTrader?

          mbg
          RR
          Attached Files

          Comment


            #6
            Hello SpikeLGWG,

            The script you have has a try and catch in it I'm not quite understanding.

            But I added Print(string.Format("{0} | BIP: {1}", Time[0], BarsInProgress)); to the top of the script outside of all the code you have and I'm finding this prints just fine for each tick and 1 second bar.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi,
              i added your line to my Scirpt and get this result:
              Code:
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              11.03.2021 22:45:00 | BIP: 0
              No second and no other Timefrime.
              In Backtesting this would work ok, but in Live i get this posted result.

              mbg
              RR

              Comment


                #8
                Hello RR,

                Below is a link to a video of the test.


                If you follow the exact steps in this video, do you experience different behavior?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  you show me, how the OnBarUpdate works for historical Data, and i wrote many times, this works as excpeted and i have no Problem on historical Data.

                  But on Live, so the realy Market it didn't work.

                  I have the complet same behavior an my indicator as in your video.
                  Please start the indicator you modified, and show me what happend when the blue line is printed and the indicator process the live ticks

                  Comment


                    #10
                    Hello SpikeLGWG,

                    Chelsea had commented out the Values[0][0] line so it is not drawn in his video.

                    I have recorded a demonstration testing your script verbatim and also switching to the code to use Chelsea's print:

                    Demo - https://drive.google.com/file/d/1GET...w?usp=drivesdk

                    I am seeing BarsInProgress 0, 1 and 2 with historical and realtime in this test, and enabling Tick Replay does not change the data series I am seeing with realtime prints.

                    If you are seeing results when testing the same where the other data series are not seen, please ensure you are updated to the latest version and also test in a clean environment for a sanity check.

                    If issues persist, please then contact me at scriptingsupport [at] ninjatrader [dot] com with the text "Attn Jim 3005518" I may then would like to schedule a time to test this script on your PC and note any differences that are seen and any environmental differences.

                    Comment


                      #11
                      realy strange,
                      i wrote you an Mail with an Video.

                      mbg
                      RR

                      Comment


                        #12
                        To close this ticket, the Reason for this Problem was the Connector.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        579 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        334 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        554 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        551 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X