Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to reset blockcount each bar

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

    How to reset blockcount each bar

    I have some code that draws a histogram using time and sales data volume. The idea is to plot the quantity of block trades for each bar. I have the code counting but the blockcount variable is cumulating each bar.

    How do I reset the blockcount variable to zero at the start of a new bar?

    Here is the code:

    /// //initialize the blockcount variable

    int blockcount = 0;


    protected override void OnMarketData(MarketDataEventArgs e)
    {


    //Increment blockcount each time a trade of 1000 shares or greater comes in

    if (e.MarketDataType == MarketDataType.Last && e.Volume >=5)
    {
    blockcount++ ;
    }

    }
    protected override void OnBarUpdate()
    {

    Blocks.Set(blockcount);
    }

    #2
    gdavis74, you could reset your custom tracking variable in FirstTickOfBar in the OnBarUpdate() -

    Comment


      #3
      Bertrand, thanks for the quick response. That worked perfectly, I was able to monitor blocktrades today!

      Comment

      Latest Posts

      Collapse

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