Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars In Progress Bug?

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

    Bars In Progress Bug?

    The Following Code produces what seem to be erratic price data. Confirmed with an SMA reading. Code matches output window.

    My primary data chart is 15 min, and from the code you can see i have 3 more Bars in progress settings. One of which is 15 min as well, to match the On bars update. When taking the SMA of the same time (1 min bars) the values printed from OnBarUpdate() can be different from those within BarsInProgress = 15 minute. Which seems to make no sense if the primary bar (whats on your chart) is the same as adding a new periodtype of 15 minutes.

    One thing i have noticed: Printing the close within the OnBarUpdate() Method on a 15 minute chart will print every minute but sometimes with multiple print statements of the exact time (in this case 1 min increments) with the same price. - This is what i am guessing is throwing off the SMA values. Although when there is no tick data present as 1 minute is the smallest increment, how is this happening?



    Code:
     protected override void Initialize() 
            {
           		Add(PeriodType.Minute,15); //1
    			Add(PeriodType.Minute,5); //2
    			Add(PeriodType.Minute,1); //3 
    		}//initialize 
    
           protected override void OnBarUpdate() // primary bar series - Timing is linked to the Smallest Period Value Initialized. In This Case == 1 minute. 
          	{
    				PrintWithTimeStamp("OBU-----" + Close.ToString()); 
    				PrintWithTimeStamp("SMA of OBU-----" + SMA(Close,5)[0]); 
    			// Prints Close value every minute
    				// bip == 0??? Which would be the primary bar series which in this case is set to a 15 min bar on the chart.
    				// Why When running this segment of code within onbarupdate() does the Close Print multiple times with the same time and the same price on historical data? 
    				// cont from above...it appears this will cause calculations to be off if figuring SMA's  etc...As it will overly smooth out the price depending on how many times the 
    			// same price is evaluated within 1 time period, i.e. 1 minute yet 3 print statements at time 3:00 with 3 exact prices of 700.1    ??? /* */ 
    			
    			if (BarsInProgress ==2) // 5 minute bars
    				{
    					PrintWithTimeStamp("BIP==2---------" + Close.ToString()); // 	
    					// prints trailing stop value every 5 minutes, 
    					// bip==1 = period type 1 , secondary bar series 
    				}
    				
    			if ( BarsInProgress ==3) // 1 minute bars 
    				{
    					PrintWithTimeStamp("SMA of BIP 3-----" + SMA(Close,5)[0]); 
    					PrintWithTimeStamp("BIP==3---------" + Close.ToString());
    					// prints trailing stop value every 1 minutes, 	
    					// bip ==2 = period type 2, third bar series. 
    				}   	
    		
    			if (BarsInProgress == 1) // 15 min bars, Added because onbarupdate syncs up with the smallest period type specified within the initialize() method. 
    				{
    					PrintWithTimeStamp("BIP==1-------------" + Close.ToString()); 
    					PrintWithTimeStamp("SMA of BIP 1-----" + SMA(Close,5)[0]); 
    					// prints trailing stop value every 15 minutes
    					// bip==3, period type2, fourth bar series 
    				}
    			
    		/****************************************** If Method is located within a barsinprogress {} then it will only update per the bars in progress index setting*********************************/ 	
    		// Notes. Calculations onbarupdate() with multitimeframes may not be accurate, run calculations within intended BIP Time window. BIP=DataSeries. 
    
    		}  	// onbarupdate


    2/3/2011 3:15:00 PM OBU-----796.2

    2/3/2011 3:15:00 PM SMA of OBU-----796.840000000003

    2/3/2011 3:15:00 PM BIP==2---------796.2

    2/3/2011 3:15:00 PM OBU-----796.2

    2/3/2011 3:15:00 PM SMA of OBU-----796.400000000009

    2/3/2011 3:15:00 PM SMA of BIP 3-----796.400000000009

    2/3/2011 3:15:00 PM BIP==3---------796.2

    #2
    neb1998, you have no filter here for the BIP0 added, the first 2 Prints would be then called for each separate BIP, I suggest adding BarsInProgress into the prints as well to see it.

    Comment


      #3
      Ok so i add a BIP==0, Thats fine. The issue is...What is calculating onbarupdate() ? Is this every second? Randomly? It just does not appear to fit any of the periods specified, either primary or additional period types added through initialize()

      Comment


        #4
        It's calculating according to your CalculateOnBarClose setting - if 'false', it updates on every tick for each series, if 'true' it calculates then on each series bar close (i.e. 1 min, 5 min, 15 min).

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 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
        567 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