Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsInProgress with strategy analyzer

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

    BarsInProgress with strategy analyzer

    I noticed that when I backtest there are chunks of my code that are never reached.

    my Initialize() looks as follows

    Code:
    protected override void Initialize()
            {
                Add("ES 06-10", PeriodType.Minute, 1);
                Add("YM 06-10", PeriodType.Minute, 1);
                Add("NQ 06-10", PeriodType.Minute, 1);
                SetTrailStop("", CalculationMode.Ticks, 57, false);
                SetProfitTarget("", CalculationMode.Ticks, 71);
                BarsRequired = 1;
                ExitOnClose = true;
                ExitOnCloseSeconds = 30;
                TimeInForce = Cbi.TimeInForce.Day; 
                CalculateOnBarClose = true;
            }
    The thought being that BarsInProgress 0 is the TF (chart traded from) and the ES is 1 etc...

    However in my OnBarUpdate()
    Code:
    protected override void OnBarUpdate()
            {
                    
    if(Bars.FirstBarOfSession){
         TradesPerDay = 0;
     }
    
    
    if (BarsInProgress == 0){
        ..............
    }
    else if (BarsInProgress == 1){
        Print("THIS IS NEVER HIT");
        ..............
    }
    
    ...........................
    }
    The point of the system is that it will trade in the TF when it receives signals from both itself and these three other markets. Is there an obvious reason why nothing after the first BarsinProgress gets called?

    #2
    shazzmoe, I just tested this on my end and got the expected output. I see you have quite a bit of .... in your strategy. Could those other conditions be preventing your secondary BIP index from being reached?

    This is the code I ran:
    Code:
    // ran on ES 09-10 1min
    protected override void Initialize()
    {
        CalculateOnBarClose = true;
        Add("TF 09-10", PeriodType.Minute, 1);
    }
    
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
        if (BarsInProgress == 0)
        {
            Print("primary instrument close: " + Close[0]);
        }
        else if (BarsInProgress == 1)
        {
            Print("secondary instrument close: " + Close[0]);
        }
    }
    Which produced this output:
    Code:
    primary instrument close: 1117.5
    secondary instrument close: 656.8
    primary instrument close: 1117
    secondary instrument close: 656.5
    primary instrument close: 1117
    secondary instrument close: 656.3
    primary instrument close: 1116.5
    secondary instrument close: 655.8
    primary instrument close: 1117
    secondary instrument close: 655.9
    primary instrument close: 1116.5
    secondary instrument close: 655.4
    primary instrument close: 1116.5
    secondary instrument close: 655.5
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Christopher Leggit, 02-15-2024, 09:00 AM
    3 responses
    45 views
    0 likes
    Last Post rdtdale
    by rdtdale
     
    Started by DavidHP, Today, 07:56 AM
    0 responses
    2 views
    0 likes
    Last Post DavidHP
    by DavidHP
     
    Started by Aviram Y, 08-09-2023, 09:04 AM
    10 responses
    298 views
    0 likes
    Last Post MrHump
    by MrHump
     
    Started by jpapa, Today, 07:22 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by kevinenergy, 02-17-2023, 12:42 PM
    116 responses
    2,758 views
    1 like
    Last Post kevinenergy  
    Working...
    X