Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Standard Deviation for Volume Issues

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

    Standard Deviation for Volume Issues

    Hello, I'm trying to create a standard deviation for volume and running into issues.Essentially this should be like a Bollinger Band code, but it isn't working.

    here is the code from the indicator:

    Code:
    		else if (State == State.DataLoaded)
    			{
    	
    				stdDev	= StdDev(Period);
    				
    			}
    		}
    
    		protected override void OnBarUpdate()
    		{
    			double stdDev0	= stdDev[0];
    			
    			if (State == State.Historical)
    			{
    				Value[0] = Volume[0];	
    				Upper[0] = Value[0] + NumStdDev * stdDev0;
    
    			}
    			else
    			{		
    				Value[0] = Bars.TickCount;
    				Upper[0] = Value[0] + NumStdDev * stdDev0;
    
    			}
    NumStdDev = 2;
    Period= 20;

    Attached is an image of the indicator. Even if I put Period at some really high number, it doesn't change the indicator. It looks like "Upper[0]" is just plotting "Value[0]", Upper is the white line on top of the blue bars. Essentially I should be getting a relatively straight line across like the yellow one I have drawn in.

    Any idea why this code isn't working?

    Thanks
    Attached Files

    #2
    Hello EC_Chris,

    Thank you for your note.

    I would suggest adding prints to your script.

    It could be that “NumStdDev * stdDev0” comes out to be a tiny number, and thus adding it to Value[0], makes it difficult to see this component of this.

    Prints might look like,

    Code:
    Print(NumStdDev*ToString()+”___>”+stdDev0.ToString());
    I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:



    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan, but I actually was able to resolve it right after I posted. Sorry about that. Appreciate your response.

      Comment

      Latest Posts

      Collapse

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