NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-26-2011, 04:30 AM   #1
rzeemeijer
Junior Member
 
Join Date: Jan 2011
Posts: 8
Thanks: 0
Thanked 0 times in 0 posts
Default Stochastics cross

Hello,

How do you code %K cross below %D with the strategy wizard.

Will the system trade only when the cross takes place or during the period %K < %D.

Thank you.

Kind regards,

Rene Zeemeijer
rzeemeijer is offline  
Reply With Quote
Old 10-26-2011, 04:38 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,398
Thanks: 252
Thanked 968 times in 951 posts
Default

Hi Rene, if you use the dedicated CrossOver / under functions then the condition would only evaluate to 'true' once a cross is seen, and not just %K being greater then %D or vice versa.

Please review the 7th section in this link from our helpguide for how to define a CrossOver condition in the wizard - http://www.ninjatrader.com/support/h...on_builder.htm

Thanks,
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 04-26-2013, 10:06 AM   #3
cameo86
Member
 
Join Date: Apr 2013
Posts: 44
Thanks: 18
Thanked 0 times in 0 posts
Default The cross on the K% and D%

I understand what your saying but instead of creating inputs could i switch the period. My thought process was when %K crosses above %D to go long, but i need to change the variable in order for the code to recognize the difference between %K or D%. Or do i need to simply put


&& CrossAbove(Stochastics(7, (int) (Variable0), (int) (Variable0)).D, Stochastics((int) (Variable1), 14, 3).D, 1))
{
EnterLong(1, "");
}


Or do i need to simply put as per the the link like the EMA's and MACD and it will read the %K cross above the D%
&& CrossAbove(Stochastics(7, 14, 3).D, Stochastics(7, 14, 3).D, 1))
{
EnterLong(1, "");
}


Thanks for your help in advance
cameo86 is offline  
Reply With Quote
Old 04-26-2013, 10:24 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,398
Thanks: 252
Thanked 968 times in 951 posts
Default

Hello, you can use the second call, just make sure you select the correct plot of the Stochastics to use here -

&& CrossAbove(Stochastics(7, 14, 3).K, Stochastics(7, 14, 3).D, 1))
{
EnterLong(1, "");
}
NinjaTrader_Bertrand is online now  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Old 04-26-2013, 11:10 AM   #5
cameo86
Member
 
Join Date: Apr 2013
Posts: 44
Thanks: 18
Thanked 0 times in 0 posts
Default MACD Crossover, would that be applicable to the MACD

if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1)

How would i differentiate the cross on the MACD as was done with the stochastics D &K


Thanks a bunch
cameo86 is offline  
Reply With Quote
Old 04-26-2013, 11:13 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,398
Thanks: 252
Thanked 968 times in 951 posts
Default

Should be fine already, you're checking for MACD main value and it's avg here.
NinjaTrader_Bertrand is online now  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to detect cross above of Stochastics.K/Stochastics.D, MACD.Value/MACD.Avg? qfweiwei General Programming 5 07-20-2011 10:42 PM
Stochastics Cross Indicator DennisA Market Analyzer 1 03-31-2011 07:32 AM
Price at Cross Above / Cross Below sgordet Indicator Development 7 01-11-2011 02:58 PM
Cross Above / Cross Below for NT7? Elliott Wave Market Analyzer 12 11-20-2010 05:27 PM
Stochastics vs Fast Stochastics Indicator KBJ Miscellaneous Support 4 10-17-2007 04:44 PM


All times are GMT -6. The time now is 07:07 AM.