Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Primary Bars" in a multi-time frame portfolio trading strategy

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

    "Primary Bars" in a multi-time frame portfolio trading strategy

    My goal is to trade from a portfolio of 100 stocks daily, using NinjaTrader 8.

    I want to use three time frames when calculating the OPEN and CLOSE triggers. (5, 10. and 15 minute bars.)

    I am confused about the concept of “primary bars” when trading a portfolio.

    The structure of the strategy will calculate only one instrument to see if it is viable to trade. Since the strategy will not be applied to a chart, I am unclear how the concept of “primary bars” would be defined.

    Should I use “AddDataSeries” for each of the 5, 10, and 15 minute increments, and then, when a different time period is needed use a “BarsArray” designation?

    As I understand it, every aspect of the strategy would need a “BarsArray” number. I would never use the “Primary Bar” object.

    Is this thinking correct?
    Last edited by ArmKnuckle; 10-04-2015, 10:10 PM.

    #2
    Hello ArmKnuckle,

    Thanks for your post and welcome to the forums.

    All strategies will have a primary bars object. Even though you will not be using charts, when you apply the strategy you will need to select the instrument and timeframe that the strategy is applied to, thus creating the strategies primary bars.

    If I understand correctly your lowest timeframe is 5 minute bars. In that case that is what you would enter when applying the strategy thus the 5 minute bars are the primary bars and can be referred to as BarsArray[0]. Each added dataseries would then be (10 minute) BarsArray[1] and (15 minute) BarsArray[2]

    Another important concept to understand is that each of the 3 bars objects will call the OnBarUpdate method where your code is. That means the references could change in each case. For example: if (SMA(20)[0] > SMA(50)[0]) would reference the calling bars object, so in the case of 5 minute bars the SMA would be pointing to 5 minute bars. In the case of 10 minute bars the SMA are now point to SMA(20) and SMA(50) on 10 minute bars (clearly not the same thing!) and so on with the 15 minute bars. In these cases you could control which bar calls the OnBarUpdate by checking the "BarsInprogress". BarsInProgress = 0 for the 5 minute bars, =1 for 10 minute and = 2 for 15 minute. Your code then be bracketed by:
    if (BarsInProgress== 0)
    {
    // do your 5 minute stuff here
    }
    if (BarsInProgress == 1)
    {
    // do your 10 minute stuff here
    }

    So can also mix them as this example shows

    if (BarsInprogress == 0)
    {
    if (SMA(BarsArray[2], 20)[0] > SMA(BarsArray[2], 50)[0]) // Looking at 15 minute SMAs
    {
    // do something here in the 5 minute bars in progress
    }
    }

    I highly recommend that you read the entire section in the helpguide on MultiTime frame as there are a number of considerations that will save you time in the long run: http://ninjatrader.com/support/helpG...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Re: "Primary Bars" in a multi-time frame portfolio trading strategy

      For clarification, I have read "Multi-Time Frame & Instruments" and am still unclear on some things.


      As stated in your previous reply:

      "Your lowest timeframe is 5 minute bars. In that case that is what you would enter when applying the strategy thus the 5 minute bars are the primary bars."

      5 minutes bars are my lowest timeframe bars, as you stated.

      The part where I need clarification is the sentence afterward.

      "In that case that is what you would enter when applying the strategy thus the 5 minute bars are the primary bars."

      How does strategy know that 5 minutes is my lowest timeframe bars if it is never specifically stated in the strategy? This might be resolved when I apply my 100 instrument portfolio strategy to trade live. Is that where the lowest timeframe 5 minute bars are defined/presented as primary?

      Is there a section that describes, in clear detail, how to apply a finished strategy with undefined primary bars to trade a portfolio of instruments?

      Comment


        #4
        Hello ArmKnuckle,

        Thank you for your response.

        Primary bars will always be present.
        The Primary bars will be the bar type on the chart your apply the strategy to or the select bar type in the Strategies menu on the Strategies tab of the Control Center.

        While we do not have a tutorial on multiple series strategies, I would recommend first reviewing our information on running automated strategies and then testing the SampleMultiTimeFrame strategy that comes preloaded in NinjaTrader to understand how this works further.

        Running Automated Strategies: http://ninjatrader.com/support/helpG...strategies.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maybeimnotrader, Yesterday, 05:46 PM
        5 responses
        24 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by NRITV, Today, 01:15 PM
        0 responses
        2 views
        0 likes
        Last Post NRITV
        by NRITV
         
        Started by quantismo, Yesterday, 05:13 PM
        2 responses
        16 views
        0 likes
        Last Post quantismo  
        Started by frankthearm, Today, 09:08 AM
        6 responses
        26 views
        0 likes
        Last Post frankthearm  
        Started by adeelshahzad, Today, 03:54 AM
        5 responses
        33 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X