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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      43 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      68 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      56 views
      0 likes
      Last Post CarlTrading  
      Working...
      X