Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Indicator run twice in historical data + time stamp

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

    Indicator run twice in historical data + time stamp

    Hi,

    1. Is Time stamp (using Time) is the time of the end bar or start bar Time?(according what I see is the end of bar time)

    2. Indicator run twice in historical data
    When I ran historical data it seems that OBU is trig twice why?
    for test I just create indicator that do nothing and insert a print in the beginning of its OnBarUpdate()
    protected override void OnBarUpdate()
    {
    Print("KobiEMA: CurrentBar = " + CurrentBar + " " + "Open = " + Open[0] + " " + "Close = " + Close[0] + " " + "High = " + High[0] + " " + "Low = " + Low[0] + " " + Time[0].ToString());

    }

    please see the following log after filtering

    $ cat /cygdrive/c/Users/Kobi45/Documents/Log/output.txt | grep "16:31:00"

    KobiTest: CurrentBar = 60 Open = 176.67 Close = 176.78 High = 176.81 Low = 176.66 29/10/2013 16:31:00
    KobiTest: CurrentBar = 450 Open = 177.2 Close = 177.15 High = 177.21 Low = 177.13 30/10/2013 16:31:00
    KobiTest: CurrentBar = 840 Open = 175.83 Close = 175.79 High = 175.86 Low = 175.77 31/10/2013 16:31:00
    KobiTest: CurrentBar = 1230 Open = 175.91 Close = 175.94 High = 175.94 Low = 175.86 01/11/2013 16:31:00
    KobiTest: CurrentBar = 1560 Open = 176.69 Close = 176.69 High = 176.74 Low = 176.66 04/11/2013 16:31:00
    KobiTest: CurrentBar = 1950 Open = 176.14 Close = 176.18 High = 176.23 Low = 176.13 05/11/2013 16:31:00
    KobiTest: CurrentBar = 2340 Open = 177.03 Close = 177.05 High = 177.13 Low = 177 06/11/2013 16:31:00
    KobiTest: CurrentBar = 2730 Open = 177.5 Close = 177.44 High = 177.56 Low = 177.44 07/11/2013 16:31:00
    KobiTest: CurrentBar = 60 Open = 176.67 Close = 176.78 High = 176.81 Low = 176.66 29/10/2013 16:31:00
    KobiTest: CurrentBar = 450 Open = 177.2 Close = 177.15 High = 177.21 Low = 177.13 30/10/2013 16:31:00
    KobiTest: CurrentBar = 840 Open = 175.83 Close = 175.79 High = 175.86 Low = 175.77 31/10/2013 16:31:00
    KobiTest: CurrentBar = 1230 Open = 175.91 Close = 175.94 High = 175.94 Low = 175.86 01/11/2013 16:31:00
    KobiTest: CurrentBar = 1560 Open = 176.69 Close = 176.69 High = 176.74 Low = 176.66 04/11/2013 16:31:00
    KobiTest: CurrentBar = 1950 Open = 176.14 Close = 176.18 High = 176.23 Low = 176.13 05/11/2013 16:31:00
    KobiTest: CurrentBar = 2340 Open = 177.03 Close = 177.05 High = 177.13 Low = 177 06/11/2013 16:31:00
    KobiTest: CurrentBar = 2730 Open = 177.5 Close = 177.44 High = 177.56 Low = 177.44 07/11/2013 16:31:00

    #2
    Correct, NT stamps the bars with their closing time.

    OnBarUpdate() should be called once for each bar, is there only one series in your script so you would get called on the primary only?

    Could it be the indicator is added two times to a chart / MA in your setup?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I have only one series in my scirpt and the indicator was added only once.
      I added the indicator and press the apply button of the UI indicator window.

      my indicator look like this

      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      Overlay = false;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      Plot0.Set(Close[0]);
      Print("MyCustomIndicator: BarsInProgress = " + BarsInProgress + " CurrentBar = " + CurrentBar + " Open = " + Open[0] + " Close = " + Close[0] + " High = " + High[0] + " Low = " + Low[0] + " " + Time[0].ToString());

      }

      Comment


        #4
        Ok, and you the output before the single run is cleaned up from any previous debug runs? So it would not persist any of your prints?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          yes I first cleaned up the output from the previous run (the output windows was clean)
          and then run a new test.

          Comment


            #6
            That should not be the case, which instrument and timeframe are you working on?

            What I see now is that KobiTest is printed, yet from your code one would expect KobiEMA - are you mixing up testing studies here perhaps?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I am using the spy instrument and timeframe of 1 Min.
              The log is OK , this just copy past Issue.

              here is a new log (after clean up the output window) corresponding to the right code

              protected override void Initialize()
              {
              Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
              Overlay = false;
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
              // Use this method for calculating your indicator values. Assign a value to each
              // plot below by replacing 'Close[0]' with your own formula.
              Plot0.Set(Close[0]);
              Print("MyCustomIndicator: BarsInProgress = " + BarsInProgress + " CurrentBar = " + CurrentBar + " Open = " + Open[0] + " Close = " + Close[0] + " High = " + High[0] + " Low = " + Low[0] + " " + Time[0].ToString());

              }

              $ cat /cygdrive/c/Users/Kobi45/Documents/Log/output.txt | grep "22:59:00"
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 1948 Open = 176.81 Close = 176.87 High = 176.9 Low = 176.8 04/11/2013 22:59:00
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 2338 Open = 176.38 Close = 176.34 High = 176.4 Low = 176.33 05/11/2013 22:59:00
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 2728 Open = 177.06 Close = 177.09 High = 177.09 Low = 177.05 06/11/2013 22:59:00
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 3118 Open = 174.85 Close = 174.9 High = 174.93 Low = 174.76 07/11/2013 22:59:00
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 1948 Open = 176.81 Close = 176.87 High = 176.9 Low = 176.8 04/11/2013 22:59:00
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 2338 Open = 176.38 Close = 176.34 High = 176.4 Low = 176.33 05/11/2013 22:59:00
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 2728 Open = 177.06 Close = 177.09 High = 177.09 Low = 177.05 06/11/2013 22:59:00
              MyCustomIndicator: BarsInProgress = 0 CurrentBar = 3118 Open = 174.85 Close = 174.9 High = 174.93 Low = 174.76 07/11/2013 22:59:00

              Comment


                #8
                Sorry, what would that exactly mean?

                $ cat /cygdrive/c/Users/Kobi45/Documents/Log/output.txt | grep "22:59:00"

                You log the output window print via custom code?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  No, I just wrote a new indicator for test named MyCustomIndicator.

                  I ran the indicator and save the contains of the output screen to a file named Output.txt using the save as option (right click of mouse from the output screen)

                  I opened the Output.txt log file from UNIX terminal .
                  In order to show that its ran twice I filtered data using UNIX command to see all data relevant to time of 22:59:00 by using the grep command
                  $ cat /cygdrive/c/Users/Kobi45/Documents/Log/output.txt | grep "22:59:00"

                  I can send you all the log file but I don not how to attach file from the forum

                  Comment


                    #10
                    Can you please send me your indicator and log to support at ninjatrader dot com?
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                    4 responses
                    542 views
                    0 likes
                    Last Post PaulMohn  
                    Started by GLFX005, Today, 03:23 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post GLFX005
                    by GLFX005
                     
                    Started by XXtrader, Yesterday, 11:30 PM
                    2 responses
                    11 views
                    0 likes
                    Last Post XXtrader  
                    Started by Waxavi, Today, 02:10 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Started by TradeForge, Today, 02:09 AM
                    0 responses
                    14 views
                    0 likes
                    Last Post TradeForge  
                    Working...
                    X