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 sjsj2732, 03-23-2026, 04:31 AM
    0 responses
    69 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    312 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    306 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    146 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    105 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X