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

Creating time comparisons

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

    Creating time comparisons

    Hi,

    I've been reading the docs at: https://ninjatrader.com/support/help...on_builder.htm

    I'm wondering if I could get an example of the following time comparison:

    -Compare the close of the current bar versus the close of the bar at 10am on a 10 minute chart.

    I understand there are two approaches to do this, where we can either count bars since session open, or we can import the 10 minute chart for the instrument we care about, and perform some comparison between timestamps. I'm not clear on this approach.

    can you give examples of what each would look like in the strategy builder?

    regards,
    Last edited by Conall; 08-08-2023, 06:08 PM.

    #2
    Hello Conall,

    Thank you for your post.

    For the approach where you "count bars since session open" I'm not sure I'm following your train of thought. Please provide a more detailed description of what you are referring to so I may better understand and assist you. For example, depending on the value of the primary series you may not be able to get the close of the bar at 10am if there is not a bar that also closes at 10am for that bar value.

    Also, are you referring to the bar that finishes forming at 10am, or do you mean the bar that starts at 10am and finishes at 10:10am on a 10-minute chart? I just want to be sure we're on the same page so the examples I create make sense and are in line with what you are looking for.

    I look forward to your clarification.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hi emily,

      It would be the bar that finishes forming at 10am, on a 5 minute time series.

      I'd like to do a comparison between the close of this bar, and a subsequent bar, either via timestamp (e.g the bar at 10am vs the bar at 10:15am) or via bar count( e.g if we know it's bar 20 on a 5 minute chart in Regular trading hours, then we can compare by bar count.

      regards,
      C

      Comment


        #4
        Hello C,

        Thank you for your reply.

        The simplest way to do this would be via timestamp and not by bar count. Bars are timestamped with the closing time of the bar, so the condition would check if the time for the bar is 10am. There are many variables involved with bar counts, and if you happen to change the timeframe of the chart or the trading hours used, this could throw off the count so you are not getting the desired value to compare to. I suggest creating a double variable that will hold the value of the Close price at 10am. You could save the 10am bar price for the primary instrument the strategy is applied to, or you could add a data series for the desired instrument and save that value. Here is an example where I add a 10-minute data series, create a double variable, then set up a condition to check if the current close price is greater than the 10am close price from the 10-minute data series:


        This uses the concept of how to create time comparisons like the example here:


        The 10-minute series was added via the "Additional data" screen and the variable was created on the "Inputs and Variables" screen:


        Please let me know if I may be of further assistance.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Hi Emily,

          From one support engineer to another, thanks for the clear explanation

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          160 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          9 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X