Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    -EC_Chris-
    NinjaTrader Ecosystem Vendor - Emergent Cybernetics

    #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:

    Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...


    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.
      -EC_Chris-
      NinjaTrader Ecosystem Vendor - Emergent Cybernetics

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by maybeimnotrader, Today, 05:46 PM
      0 responses
      6 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      6 views
      0 likes
      Last Post quantismo  
      Started by AttiM, 02-14-2024, 05:20 PM
      8 responses
      166 views
      0 likes
      Last Post jeronymite  
      Started by cre8able, Today, 04:22 PM
      0 responses
      8 views
      0 likes
      Last Post cre8able  
      Started by RichStudent, Today, 04:21 PM
      0 responses
      5 views
      0 likes
      Last Post RichStudent  
      Working...
      X