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 helpwanted, Today, 03:06 AM
    1 response
    11 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    9 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X