Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

C# Newbie -- Helpful Percentage Loaded Function

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

    C# Newbie -- Helpful Percentage Loaded Function

    Hey there, just sharing something that might help while you are debugging. I found that when loading intraday I wanted to get a better sense of how much was left to process, so I made this function to do it.

    Code:
            // You can paste this anywhere inside the "public class <your indicator name> : Indicator" block of code, right before the  "protected override void OnStateChange()" block
    
            // Function that displays chart loading progress for debug
            public void chartLoadProgress(string myTimeframe) // Takes "Intraday" or "Daily" edit as needed
            {
                double tempProgress = 0;
                double loadedProgress = 0; // For % loaded counter
                double myBars = 0;
    
                if (myTimeframe == "Intraday")
                {
                    myBars = Convert.ToDouble(CurrentBars[0]);
                }
                else if (myTimeframe == "Daily")
                {    
                    myBars = Convert.ToDouble(CurrentBars[1]);
                }
    
                tempProgress = (myBars / Convert.ToDouble(Count));
                loadedProgress = Math.Round(tempProgress, 2, MidpointRounding.AwayFromZero) * 100;
    
                if (loadedProgress < 100)
                {
                    Print("Chart load progress: " + loadedProgress + "%");
                }
            }​
    To use, just call the function anywhere in the "protected override void OnBarUpdate()" block, optionally you can specify what series you are dealing with, if you're doing multi-timeframe like this:

    Code:
            protected override void OnBarUpdate()
            {
    
                if(BarsInProgress == 0) // Primary intraday bar series
                {
                    chartLoadProgress("Intraday"); // Display loaded percentage​
                }
    
            }
    Of course if you were using it for Daily you'd have it inside a statement like "BarsInProgress == 1" and such... easy enough to edit for your own usage depending on what data series you have.

    Enjoy!

Latest Posts

Collapse

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