Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate not firing on every tick?

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

    OnBarUpdate not firing on every tick?

    Hello When I have CalculateOnBarClose set to false, I thought that OnBarUpdate would fire on every tick. But it is only firing once on close of each bar. I am running the test on TICK data, and the chart is a 21 RANGE chart. Here is a dummy strategy:
    protected override void Initialize()
    { CalculateOnBarClose = false; }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 0)
    {
    EnterLong(1,"L1"
    Print("Range" + Time[0].ToString() + " " + Close[0].ToString() + " " + CurrentBar.ToString());

    This is what I get:
    Range 13/06/2008 11:32:00 1.9505 252
    Range 13/06/2008 11:41:00 1.9494 253
    Range 13/06/2008 12:06:00 1.9487 254
    Range 13/06/2008 12:57:00 1.9485 255
    Range 13/06/2008 14:13:00 1.9472 256
    Range 13/06/2008 16:05:00 1.9478 257
    Range 13/06/2008 17:02:00 1.947 258
    Range 13/06/2008 17:54:00 1.9467 259

    Your help will be most appreciated. I have another issue with this strategy which I will raise as a separate thread.
    Last edited by swandro; 12-01-2008, 05:43 PM. Reason: Improved formatting

    #2
    If you are using historical data (backtesting) it only works on bar close. For real-time live trading, it will work every tick.

    Comment


      #3
      Thanks for the speedy reply. That explains it. In my backtest, I have tried to navigate around this problem by adding a 1 Tick data series, and opening and closing my trades on that (i.e. BarsInProgress = 1). In BarsInProgress = 0, I test FirstTickOfBar. If true, I then do my trading in BarsInProgress = 1 )the tick series. BUT..... the FirstTickOfBar on the Range chart is firing a number of ticks earlier than the tick data series. I will post an output in a separate message that illustrates this.

      Comment


        #4
        Sorry I have no further advice for you -- I tried developing a strategy using tick level data for backtesting once and gave up, mainly because of the amount of memory it required and therefore I couldn't backtest large periods.

        I ultimately decided it was better to backtest for 1, 2, 3 years on 1 minute data instead of 1 month on tick level data.

        GL!

        Comment


          #5
          Here is some actual data. Notice when you see FirstTickOfBar, this has fired in BarsInProgress=0. All the other rows are printed when BIP=1 (the tick data series) The tick that caused the start of a new range bar is dozens of ticks after the range bar claimed to have changed.


          Tick Data 13/06/2008 14:12:00 1.9474 987412
          Tick Data 13/06/2008 14:12:00 1.9474 987413
          FirstTickOfBar fired 13/06/2008 14:13:00 1.9472 256
          Tick Data 13/06/2008 14:13:00 1.9475 987414
          Tick Data 13/06/2008 14:13:00 1.9473 987415
          Tick Data 13/06/2008 14:13:00 1.9475 987416
          Tick Data 13/06/2008 14:13:00 1.9473 987417
          Tick Data 13/06/2008 14:13:00 1.9473 987418
          Tick Data 13/06/2008 14:13:00 1.9474 987419
          Tick Data 13/06/2008 14:13:00 1.9474 987420
          Tick Data 13/06/2008 14:13:00 1.9473 987421
          Tick Data 13/06/2008 14:13:00 1.9473 987422
          Tick Data 13/06/2008 14:13:00 1.9474 987423
          Tick Data 13/06/2008 14:13:00 1.9473 987424
          Tick Data 13/06/2008 14:13:00 1.9473 987425
          Tick Data 13/06/2008 14:13:00 1.9474 987426
          Tick Data 13/06/2008 14:13:00 1.9475 987427
          Tick Data 13/06/2008 14:13:00 1.9474 987428
          Tick Data 13/06/2008 14:13:00 1.9474 987429
          Tick Data 13/06/2008 14:13:00 1.9475 987430
          Tick Data 13/06/2008 14:13:00 1.9473 987431
          Tick Data 13/06/2008 14:13:00 1.9473 987432
          Tick Data 13/06/2008 14:13:00 1.9473 987433
          Tick Data 13/06/2008 14:13:00 1.9473 987434
          Tick Data 13/06/2008 14:13:00 1.9474 987435
          Tick Data 13/06/2008 14:13:00 1.9474 987436
          Tick Data 13/06/2008 14:13:00 1.9474 987437
          Tick Data 13/06/2008 14:13:00 1.9474 987438
          Tick Data 13/06/2008 14:13:00 1.9474 987439
          Tick Data 13/06/2008 14:13:00 1.9474 987440
          Tick Data 13/06/2008 14:13:00 1.9474 987441
          Tick Data 13/06/2008 14:13:00 1.9474 987442
          Tick Data 13/06/2008 14:13:00 1.9475 987443
          Tick Data 13/06/2008 14:13:00 1.9473 987444
          Tick Data 13/06/2008 14:13:00 1.9473 987445
          Tick Data 13/06/2008 14:13:00 1.9475 987446
          Tick Data 13/06/2008 14:13:00 1.9473 987447
          Tick Data 13/06/2008 14:13:00 1.9474 987448
          Tick Data 13/06/2008 14:13:00 1.9474 987449
          Tick Data 13/06/2008 14:13:00 1.9473 987450
          Tick Data 13/06/2008 14:13:00 1.9474 987451
          Tick Data 13/06/2008 14:13:00 1.9475 987452
          Tick Data 13/06/2008 14:13:00 1.9474 987453
          Tick Data 13/06/2008 14:13:00 1.9472 987454
          Tick Data 13/06/2008 14:13:00 1.9473 987455
          Tick Data 13/06/2008 14:13:00 1.9473 987456
          Tick Data 13/06/2008 14:13:00 1.9474 987457
          Tick Data 13/06/2008 14:13:00 1.9475 987458
          Tick Data 13/06/2008 14:13:00 1.9474 987459
          Tick Data 13/06/2008 14:13:00 1.9473 987460
          Tick Data 13/06/2008 14:13:00 1.9474 987461
          Tick Data 13/06/2008 14:13:00 1.9474 987462
          Tick Data 13/06/2008 14:13:00 1.9474 987463
          Tick Data 13/06/2008 14:13:00 1.9474 987464
          Tick Data 13/06/2008 14:13:00 1.9474 987465
          Tick Data 13/06/2008 14:13:00 1.9475 987466
          Tick Data 13/06/2008 14:13:00 1.9472 987467
          Tick Data 13/06/2008 14:13:00 1.9473 987468
          Tick Data 13/06/2008 14:13:00 1.9472 987469
          Tick Data 13/06/2008 14:13:00 1.9472 987470
          Tick Data 13/06/2008 14:13:00 1.9472 987471
          Tick Data 13/06/2008 14:13:00 1.9472 987472
          Tick Data 13/06/2008 14:13:00 1.9473 987473
          Tick Data 13/06/2008 14:13:00 1.9474 987474
          Tick Data 13/06/2008 14:13:00 1.9473 987475
          Tick Data 13/06/2008 14:13:00 1.9472 987476
          Tick Data 13/06/2008 14:13:00 1.9472 987477
          Tick Data 13/06/2008 14:13:00 1.9473 987478
          Tick Data 13/06/2008 14:13:00 1.9474 987479
          Tick Data 13/06/2008 14:13:00 1.9472 987480
          Tick Data 13/06/2008 14:13:00 1.9474 987481
          Tick Data 13/06/2008 14:13:00 1.9473 987482
          Tick Data 13/06/2008 14:13:00 1.9472 987483
          Tick Data 13/06/2008 14:13:00 1.9474 987484
          Tick Data 13/06/2008 14:13:00 1.9473 987485
          Tick Data 13/06/2008 14:13:00 1.9472 987486
          Tick Data 13/06/2008 14:13:00 1.9471 987487

          Last edited by swandro; 11-29-2008, 07:23 PM. Reason: Formatting

          Comment


            #6
            Thanks ctrlbrk. I am very new to this and I heed your advice. If Ninja Support cannot save me I will have to think again.

            Comment


              #7
              Your posts are very hard to read/follow because of line formatting. You might try wrapping the text with the 'code' markers, using the editor toolbar it's the # symbol, or just make sure each line ends in a newline command.

              Comment


                #8
                I have formatted the data - again, thanks for the help.

                Comment


                  #9
                  Support - I would most welcome your assistance on this. This plainly looks wrong to me and I need to understand why.

                  Your help is much appreciated.

                  Comment


                    #10
                    Hi swandro,

                    Thanks for your patience!

                    It looks like your tickdata is missing timestamps to the second, therefore your PC clock is used for stamping any incoming ones...so first I would suggest synching your PC clock up regularly - here's how to do it:

                    You can sync your PC clock by double clicking on the clock in the lower right corner of your desktop. Once you have done that, click on Internet Time tab and then click Update. Your PC clock should now be updated.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    571 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    330 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    549 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    549 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X