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

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 adeelshahzad, Today, 03:54 AM
    5 responses
    31 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by stafe, 04-15-2024, 08:34 PM
    7 responses
    31 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by merzo, 06-25-2023, 02:19 AM
    10 responses
    823 views
    1 like
    Last Post NinjaTrader_ChristopherJ  
    Started by frankthearm, Today, 09:08 AM
    5 responses
    18 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    43 views
    0 likes
    Last Post jeronymite  
    Working...
    X