Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator help

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

    indicator help

    can anyone help me build an indicator that will signal when stochastic K and stochastic D are a desired number apart ?

    thanks

    #2
    Hello benrock,

    To start you can create a new indicator with the original code from another indicator by going to the Control Center -> Tools -> Edit NinjaScript -> Indicators. Then double left click on the indicator that you want to have the original code from for example the "Stochastics". It will then open up the source code for the indicator. Right click inside the window and select Save As. Type in a name of your choosing then press "Save". Press the "OK" button. Now you have a new indicator based off the system indicator code that you can modify to set signals.

    With your newly created indicator open you can add some custom code to set some signal conditions. For example:

    Code:
    protected override void OnBarUpdate()
    {
          nom.Set(Close[0] - MIN(Low, PeriodK)[0]); 
    (…)
    	D.Set(SMA(K, PeriodD)[0]);
    
    	
    	//Declaring test variable for Stochastic K & D difference
    	int stochasticDiff = 3;
    			
    	//Checks to see if the difference between K & D is equal to stochasticDiff
    	if((K[0] – D[0]) == stochasticDiff || (K[0] – D[0]) == -stochasticDiff)
    	{
    		// Set Signal in here
    	}
    }
    For more information about the Stochastics indicator you may read the following link.


    Here is a link to our support forums that goes over how to debug your code which comes in handy if you run into a compiling errors when writing custom code.


    Please let me know if I can be of further help.
    JCNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

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