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

IntraBar TickTime with CalculateOnBarClose=false

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

    IntraBar TickTime with CalculateOnBarClose=false

    Dear Forum,

    I'm processing a DataSeries with TimePeriod 'Minute' (i.e. 1 Min Chart) and CalculateOnBarClose=false. With each incoming tick triggering OnBarUpdate(), I see within Time[0] always the time 'naming' the current bar (i.e. 12:01:00, 12:02:00, ...).

    Is there a field/var/method containing the 'IntraBar TickTime' (i.e. 12:01:07)?

    At least I found Bars.PercentComplete, so I could calculate my 'TickTime' from that - guessing that Bars.PercentComplete has been calculated from exact that time value I'm looking for.

    Is there a(n easy) way, to 'read out' the 'TickTime' ?

    Many thanx in advance,

    mtp65

    #2
    Hello,

    Thank you for the question.

    Time[0] would refer to the current bar so on a minute chart you would not get the expected output.

    Instead you could either use OnMarketData to get the Last value and its Time




    Another way would be to add a 1 tick series to the script, if you need ticks historically this may be the better route to go, otherwise for only realtime OnMarketData would work.

    You can view a sample of a multi timeframe script by going to Tools -> Edit Strategy -> SampleMultiTimeframe


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      thank you for the quick reply.

      As my indicator should work also on historical data, OnMarketData() is not an option.

      Now I also understand, that using Bars.PercentComplete will deliver always 100% on historical data - OnBarUpdate() is called only once per minute in this example.

      Thank you for the clarification, I will add a second tick data series as suggested.

      Kind regards,

      mtp65

      Comment


        #4
        Okay,

        thank you again - now everything works perfekt!

        Here is what I did (as copied fom the sample strategie SampleMultiTimeFrame):

        Code:
        protected override void Initialize()
        {
             CalculateOnBarClose = false;
             Add(PeriodType.Tick, 1);    // Adds a second 'one tick' data series
         }
        Code:
        protected override void OnBarUpdate()
        {
              if (BarsInProgress != 0)     // We use only updates for the primary data series
                  return;
              Print(DateTime.Now+"     "+Times[1][0]+"     "+Times[0][0]+"    "+Bars.TickCount);
        }
        And that is, how the output looks like (example):

        Code:
        07.10.2015 16:53:58     07.10.2015 16:54:00     07.10.2015 16:55:00      1
        07.10.2015 16:53:59     07.10.2015 16:54:01     07.10.2015 16:55:00      2
        07.10.2015 16:54:01     07.10.2015 16:54:02     07.10.2015 16:55:00      3
        07.10.2015 16:54:01     07.10.2015 16:54:02     07.10.2015 16:55:00      4
        07.10.2015 16:54:01     07.10.2015 16:54:03     07.10.2015 16:55:00      5
        07.10.2015 16:54:02     07.10.2015 16:54:04     07.10.2015 16:55:00      6
        It seams, my PC is two seconds out of time - even I use internet time sync.

        Your hint to read (again) some of your docs was also very helpful. The following is really a MUST for 'Multi-Time-Frame' beginners working on historical AND real-time data:



        The 'bars picture' at 'How Bar Data is Referenced' should 'burn into mind' (see attachment).

        Thank you,

        mtp65
        Attached Files
        Last edited by mtp65; 10-07-2015, 09:07 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X