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

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 geotrades1, Today, 10:02 AM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by ender_wiggum, Today, 09:50 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by rajendrasubedi2023, Today, 09:50 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by bmartz, Today, 09:30 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by geddyisodin, Today, 05:20 AM
            3 responses
            26 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X