• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateBarOnClose = False

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

    CalculateBarOnClose = False

    Hi,

    I want to run a strategy based on CalculateOnBarClose = false because I need it to be aware of multiple timeframes in realtime without the need for a higher timeframe to be close. But I don't want the strategy to run the whole algorithm constantly, just at the first tick of the bar, as if it in fact were CalculateOnBarClose = true.

    So I thought how about I just put this at the top of the OnBarUpdate() method:
    Code:
    			if(!FirstTickOfBar) {
    				return;
    			}
    So now my strategy only acts on the first tick of the new bar and returns on all other ticks, saving a lot of resources. But it still is aware of the realtime multiple timeframe bar values right? So I have everything thought out properly.

    #2
    Hello,
    Thanks for posting today.

    You are correct.

    Since there are multiple time frames the FirstTick will still see the first tick of each time frame.

    Please let us know if we may be of further assistance for anything NinjaTrader.
    Alex G.NinjaTrader Customer Service

    Comment


      #3
      Thanks for answering so quickly. So how does this work during a strategy analyzer backtest on a primary timeframe of 1-min and a secondary timeframe of 15min. Will the 1-min timeframe be aware of the value of the 15-min timeframe before it is closed?

      I know it works during live trading, but wondering during backtesting

      Comment


        #4
        Hello,
        Thanks for the reply.

        It depends on how the strategy is designed. If decisions on the 1 min chart are made based on the 15 min chart it will reference back to the 15 min chart and then make decisions then.

        However, be aware that the 15 min chart may not have closed a bar before a decisions has to be made based on the 1 min chart. This may cause the strategy to make decisions based on information that you may not necessarily want it too.

        It is recommended to use the BarsInProgress() method to determine which bar is updating when making decisions.

        Here is a link to the BarsInProgress() documentation in the help guide. http://ninjatrader.com/support/helpG...inprogress.htm

        Here is a link to the help guide describing using multi-time frames and instruments. http://ninjatrader.com/support/helpG...nstruments.htm

        Please let us know if we may be of further assistance for anything NinjaTrader.
        Alex G.NinjaTrader Customer Service

        Comment


          #5
          Yes all decisions are made on the primary timeframe. I have the following statement in effect on the OnBarUpdate() method

          Code:
          if(BarsInProgress > 0 || !FirstTickOfBar) { return; }
          I just want to incorporate values of unclosed higher timeframes for the primary timeframe decision making. No actions are taken on any other bars than the primary timeframe

          So in short. The 1min is always aware of the unclosed values of higher timeframes when CalculateOnBarClose = false..

          Comment


            #6
            Hello,
            Thanks for the reply.

            Yes, this is true if you carry over some information calculated on the 15 min bar.

            When a calculation is made on the 15 min bar and sets a variable with some information, this variable can then be access in the 1 min or BarsInProgress == 0 calculations.

            You will need to do some calculations using the 15 min bar or BarsInProgress == 1 so that you can access that information later in BarsInProgress == 0. I may have not been clear in the previous post

            Please let us know if we may be of further clarification on this issue or for anything NinjaTrader.
            Alex G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Emma1, Today, 02:42 PM
            0 responses
            1 view
            0 likes
            Last Post Emma1
            by Emma1
             
            Started by RedDuke, Today, 01:59 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by MarianApalaghiei, Today, 01:18 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by williamzz, Today, 01:00 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by edmata1109, Today, 12:40 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Kate  
            Working...
            X