Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting up BarsInProgress

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

    Setting up BarsInProgress


    My MultiTimeFrame strategy has partitioning of the rules/conditions, and I have been experimenting to better understand the BIP capabilities and the design of the indicators for the best type of bars etc.


    Version 1: default/original

    #region Region_OnBarUpdate
    protected override void OnBarUpdate()
    {

    if (CurrentBars[0] < 250 || CurrentBars[1] < 250 || CurrentBars[2] < 250)
    return;
    {
    if (BarsInProgress == 0)
    #region ENTRY RULES
    // all the entry conditions based on BarsArray 0 and 1
    /* this is the default setup */
    #endregion
    #region EXIT RULES
    // all the exit conditions based on BarsArray 0 and 1 and 2
    /* this is the default setup */
    #endregion
    #region TRAILING RULES FOR "SETSTOPLOSS()"
    // all the trailing rules & conditions based exclusively on BarsArray 0 = the default setup
    /* Prints show that BarsArray0 and BarsArray1 and BarsArray2 are all making changes to the stop loss position on each bar close of the respective array. I now understand that is expected */
    #endregion

    #endregion END OF 'ON BAR UPDATES'
    }
    }
    Version 2:

    #region Region_OnBarUpdate
    protected override void OnBarUpdate()
    {

    if (CurrentBars[0] < 250 || CurrentBars[1] < 250 || CurrentBars[2] < 250)
    return;
    {

    if (BarsInProgress != 0)
    return;

    if (BarsInProgress == 0)
    #region ENTRY RULES
    // all the entry conditions based on BarsArray 0 and 1
    /* 75% fewer trades entered, so I expect that the rules based on BA1 are actually being triggered off BA0, otherwise, since the conditions require BOTH BA0 and BA1 conditions to be met there would be no trades entered */
    #endregion

    #region EXIT RULES
    // all the exit conditions based on BarsArray 0 and 1 and 2
    #endregion

    #region TRAILING RULES FOR "SETSTOPLOSS()"
    // all the trailing rules & conditions based exclusively on BarsArray 0
    /* Prints show that BarsArray0 only is making changes to the
    stop loss position on each bar close of the respective array. */
    #endregion

    #endregion END OF 'ON BAR UPDATES'
    }
    }


    Version 3:

    #region Region_OnBarUpdate
    protected override void OnBarUpdate()
    {

    if (CurrentBars[0] < 250 || CurrentBars[1] < 250 || CurrentBars[2] < 250)
    return;
    {

    if (BarsInProgress == 0)
    #region ENTRY RULES
    // all the entry conditions based on BarsArray 0 and 1
    /* 10% fewer trades entered (ie trade exits are different from version 1), and sharpe ratio and profit factor are consistent as are drawdown points*/
    #endregion

    #region EXIT RULES
    // all the exit conditions based on BarsArray 0 and 1 and 2
    #endregion

    #region TRAILING RULES FOR "SETSTOPLOSS()"

    {
    if (BarsInProgress != 0)
    return;

    // all the trailing rules & conditions based exclusively on BarsArray 0
    /* Prints show that BarsArray0 only is making changes to the
    stop loss position on each bar close of the respective array. */
    }
    #endregion

    #endregion END OF 'ON BAR UPDATES'
    }
    }

    What I am wondering is the best way to configure BIP 0 & 1 to restrict data for the ENTRY specific conditions&rules in scenario described above, and if there can be improvements overall.

    Thanks,
    Jon

    #2
    Hi Jon,

    This is a good page for understanding how bars are referenced in a multi series strategy:


    Enclosing rules that you want specific to BIP 0 in a statement like the following:

    if (BarsInProgress == 0)
    {
    //BIP0 rules here
    }

    For structuring the code to execute following an if statement, you typically use curly brackets and not regions. Regions are for easy expand / collapse of code blocks but will still need the curly brackets { }.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by junkone, 04-21-2024, 07:17 AM
    10 responses
    148 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by tsantospinto, 04-12-2024, 07:04 PM
    6 responses
    100 views
    0 likes
    Last Post tsantospinto  
    Started by rocketman7, Today, 02:12 AM
    5 responses
    26 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by ZenCortexReal, Today, 08:54 AM
    0 responses
    1 view
    0 likes
    Last Post ZenCortexReal  
    Started by ZenCortexReal, Today, 08:52 AM
    0 responses
    0 views
    0 likes
    Last Post ZenCortexReal  
    Working...
    X