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

using a different time frame

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

    using a different time frame

    I am using 30 minutes charts to run my strategies.
    However, instead of checjing parametes at 9.30, 10.00, 10,.30, etc..
    Ineedto check it at 9,33, 10.03, 10,33.
    Is it possible?

    Also, How could I check the last bar at 15,57 instead of 16:03?

    #2
    Hello,

    Thank you for the question.

    For this you would need to convert the script into a multi timeframe script, you can find more about this subject here:







    Additionally there is a Sample strategy that comes with the platform that employs this technique, it is called SampleMultiTimeFrame.



    To simplify the explanation of this, essentially you are just adding the 1 minute data series from the strategy and then doing work in OnBarUpdate dependent on which series called OnBarUpdate. You could make conditions to check for specific minutes this way.

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

    Comment


      #3
      Can I set CalculateonBarClose false until 9:35 and then change it to true?

      Can I set COBC out side Initialize()?

      Comment


        #4
        Hello,

        This property is only supported when used in Initialize, technically it could be called in OnBarUpdate without an exception but this could have serious implications on the script and would likely cause unknown results which could lead to losses.

        Instead the correct way would be to use an extra dataseries as this was the design purpose behind adding additional series. This allow you to access different timeframes as needed or execute logic at those intervals. Because you are on a Higher timeframe, you would need to add the Lower timeframe to access the smaller increments of time from the same script so OnBarUpdate is called more frequently than every 30 minutes.

        An alternitive would be to use CalculateOnBarClose = false and not add any additional series, any logic needed to be executed on the 30 minutes you could execute on the FirstTickOfBar and other logic could be executed intrabar on each tick.


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

        Comment


          #5
          My problem is.
          AS I am running the chart on 30 minutes, and set calculateonBarClose true.
          My strategy only generates the first trade at 10:00... (after the first BarsinProgress advabce).
          I need to check for my conditions at 9:35 since it uses yesterday close and I do not want to expect for the first 30 minutes to test condition. (wanna test it at 9:35).

          I have add a 5 minutes time frame with the same instrument as Ints 0 but my strategy still generates first trade at 10:00.

          Any clue?

          Comment


            #6
            Basically,the question would be.
            How can I generate a condition therefore an ORDER (just in case) at 93500, working with a 30 minutes chart, and setting calculateonBarClose to TRUE?

            Comment


              #7
              Hello,

              The answer provided in post #2 would do exactly what you have just asked.

              The BarsInProgress property would tell you which series is calling OnBarUpdate, every 30 minutes OnBarUpdate would be called for your primary series or BIP 0 in addition to every 1 minute for the secondary or BIP 1.

              In the 1 mintue series calls to OBU, you could execute logic at 1 minute intervals or at specific times of 1 minute granularity. This would be the way to do what you are asking on the bar close.

              Otherwise if the bar close is not needed and you can use the first tick as an alternative approach which is listed in post #4.

              The Multi timeframe script would be the standard approach when you need to execute logic at a different time interval than the chart series you are working with.

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

              Comment


                #8
                Originally posted by dafonseca View Post
                Basically,the question would be.
                How can I generate a condition therefore an ORDER (just in case) at 93500, working with a 30 minutes chart, and setting calculateonBarClose to TRUE?
                4 ways that I can think of:
                • Use a custom session template that starts at the required offset. The issue here is that all the bar times are going to be offset by the same amount.
                • Use a second finer time series to trigger orders.
                • Use a different event handler to issue orders. OnMarketData() readily comes to mind.
                • Create and use a Timer and its event handler to issue your order at the desired time.

                Comment


                  #9
                  The examples of script given works since intrument 0 is on 1minute timeframe while instrument 1 is on 5 minutes (slower one).
                  I am testing it,but as my intrument 0 is on 30 minutes I was not able to generate an order on a faster timeframe (5 minutes) setting calculateonBarClose TRUE.

                  As I am finding out, instrument zero timeframe all ways calls the last shot.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Aviram Y, Today, 05:29 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post Aviram Y  
                  Started by quantismo, 04-17-2024, 05:13 PM
                  3 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by ScottWalsh, 04-16-2024, 04:29 PM
                  7 responses
                  34 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by cls71, Today, 04:45 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post cls71
                  by cls71
                   
                  Started by mjairg, 07-20-2023, 11:57 PM
                  3 responses
                  217 views
                  1 like
                  Last Post PaulMohn  
                  Working...
                  X