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

Strategy: Missing Bars?

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

    Strategy: Missing Bars?

    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    ExitOnClose = false;
    BarsRequired = 0;
    Add(PeriodType.Day,1); //Add 1 day bar

    }
    protected override void OnBarUpdate()
    {
    if(BarsInProgress == 0) //Primary bar
    Print("1minbar "+CurrentBar.ToString());
    if(BarsInProgress == 1) //The added 1day bar
    Print("1daybar "+CurrentBar.ToString());
    }


    Output:
    1daybar 1
    1minbar 1146
    1minbar 1147
    1minbar 1148
    1minbar 1149
    1minbar 1150
    ...

    Why doesn't the 1min bar start at 1 ? instead of 1146. That means if I want to buy/sell on the min bar I need to wait for bar 1146. How is that acceptable ??

    If I remove the add() statement I get
    1minbar 1
    1minbar 2
    1minbar 3
    1minbar 4
    1minbar 5
    ...

    As expected
    Last edited by nohedge; 10-25-2011, 06:55 PM.

    #2
    nohedge, I ran you test as well to see what is happening here. It appears as if the first day's data is not being run through the analyzer. I will have someone else get back to you on Monday with more clarification on this.

    The test I ran used 15 minute bars instead of one minute bars (test starting 10/17) to reduce the amount of data generated:
    Code:
    10/18/2011 12:00:00 AM BIP: 0 CurrentBar: 125
    10/18/2011 12:15:00 AM BIP: 0 CurrentBar: 126
    10/18/2011 12:30:00 AM BIP: 0 CurrentBar: 127
    -snip-
    10/18/2011 11:30:00 PM BIP: 0 CurrentBar: 216
    10/18/2011 11:45:00 PM BIP: 0 CurrentBar: 217
    10/19/2011 12:00:00 AM BIP: 0 CurrentBar: 218
    10/19/2011 12:00:00 AM BIP: 1 CurrentBar: 1
    10/19/2011 12:15:00 AM BIP: 0 CurrentBar: 219
    AustinNinjaTrader Customer Service

    Comment


      #3
      missing bars

      Thanks. That would be great. Its currently blocking my evaluation process.

      Hopefully its my poor coding thats doing this!

      Comment


        #4
        nohedge, thanks for the patience - that would be expected if you add daily data to your script, even if you work on BarsRequired = 0.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          That would be expected ?..really? would that mean I have to wait days before my 1min strategy buys something?

          Can you tell me how this is documented ?


          What I want to do is find out the ATR(14day) at minute bar 0.

          //primary bar is 1 min of CROX
          protected override void Initialize()
          {
          CalculateOnBarClose = true;
          ExitOnClose = false;
          BarsRequired = 0;
          Add(PeriodType.Day,1);

          }

          protected override void OnBarUpdate()
          {

          if(BarsInProgress == 0)
          Print("1minbar "+CurrentBar.ToString());
          if(BarsInProgress == 1)
          Print("1daybar "+CurrentBar.ToString());

          }

          1daybar 1
          1minbar 1180
          1minbar 1181
          1minbar 1182
          1minbar 1183
          ...
          Last edited by nohedge; 10-25-2011, 06:37 AM.

          Comment


            #6
            nohedge, I'm not sure what you mean by 'days', but it would take one daily bar update for the OnBarUpdate() calls to come here in this config. I will a suggestion to add this to our docs, thanks for pointing that out.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            158 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Today, 09:29 PM
            0 responses
            7 views
            0 likes
            Last Post Belfortbucks  
            Started by zstheorist, Today, 07:52 PM
            0 responses
            7 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            151 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Started by mattbsea, Today, 05:44 PM
            0 responses
            6 views
            0 likes
            Last Post mattbsea  
            Working...
            X