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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    43 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    25 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    163 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X