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!
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
NinjaTrader
20% and 80% lines of stochastic indicator
Collapse
X
-
Similar question for Ninjascript
I have:
AddChartIndicator(Stochastics(stochPeriodD, stochPeriodK, stochSmooth));
The chart is displayed with indicator lines and 20 and 80. How do I change those in Ninjascript?
Thanks
Comment
-
Hello jamesmjones00123,
AddChartIndicator is a NT8 method and will not work in NT7.
To change the default value of the 2 lines as part of the Stochastics, you could use the following in NT7,
Code:protected override void Initialize() { Add(Stochastics(Close, 2,10,30)); Stochastics(Close, 2,10,30)[B].Lines[1].Value=20 ;[/B] Stochastics(Close, 2,10,30)[B].Lines[0].Value=10 ;[/B] CalculateOnBarClose = true; }
Alan P.NinjaTrader Customer Service
Comment
-
-
Hello jamesmjones00123,
Thanks for your response.
To accomplish the same thing in NT8 you could do something similar to the following snippet to set your lines to 40 and 60.
Code:else if (State == State.DataLoaded) { AddChartIndicator(Stochastics(stochPeriodD, stochPeriodK, stochSmooth)); Stochastics(stochPeriodD, stochPeriodK, stochSmooth).Lines[0].Value = 40; Stochastics(stochPeriodD, stochPeriodK, stochSmooth).Lines[1].Value = 60; }
Josh G.NinjaTrader Customer Service
Comment
-
Hello
How do I specify the condition where stochastic indicator is below (instead of cross below) the 80% line or above (instead of cross above) the 20% line in strategy builder?
I have tried following the instruction above by using "Greater" and "Less" operator but that does not seem to work.
Comment
-
Comment
-
Hello hisanoster,
Thanks for your post and welcome to the Ninjatrader forums!
To create an or condition, you would need to create a "group" with both of the conditions and set the group to "If any" (instead of the default of "if all")
Please see the help guide here for an example that creates a group (the example uses "if all"): https://ninjatrader.com/support/help...ateTimeFilters
Here are the educational resource available on the strategy builder:
Free live webinar every other Thursday at 4:00 PM EST, through this link to all webinars: https://ninjatrader.com/PlatformTraining
Previous recording of the Strategy Builder 301 webinar: https://youtu.be/HCyt90GAs9k?list=PL...auWXkWe0Nf&t=2
Help guide for the strategy builder: https://ninjatrader.com/support/help...gy_builder.htm
Paul H.NinjaTrader Customer Service
Comment
-
Hi Paul, thanks.
However, what I would like is to have all of the following conditions to be true to be qualified for order execution.
1) Stochastic K line to be greater equal than line 20
2) Stochastic K line to be less equal than line 80
3) Stochastic K line to be greaer than D line
Do you see a conflict in my conditions?Last edited by hisanoster; 01-27-2021, 08:11 PM.
Comment
-
Hello hisanoster,
Thanks for your reply.
I misunderstood/misread your conditions as wanting to be above 80 and less than 20, my mistake.
No, I do not see a conflict with your conditions.
I have attached an example of your conditions and using the Strategy Builder to show when those collective conditions are true by coloring the background of the chart silver.
Paul H.NinjaTrader Customer Service
Comment
-
Comment
-
Hello hisanoster,
Thanks for your reply.
I do not see any issues based on the limited information presented.
What I recommend would be to debug your strategy by constructing a print statement where you can print out all of the values involved in that sets conditions on a bar by bar basis and then compare your chart to those values to see what isn't working.
To assist here is a short video that demonstrates the process: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw
Paul H.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by PaulMohn, Today, 03:49 AM
|
0 responses
7 views
0 likes
|
Last Post
by PaulMohn
Today, 03:49 AM
|
||
Started by inanazsocial, Today, 01:15 AM
|
1 response
9 views
0 likes
|
Last Post Today, 02:18 AM | ||
Started by rocketman7, Today, 02:12 AM
|
0 responses
10 views
0 likes
|
Last Post
by rocketman7
Today, 02:12 AM
|
||
Started by dustydbayer, Today, 01:59 AM
|
0 responses
4 views
0 likes
|
Last Post
by dustydbayer
Today, 01:59 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
23 views
0 likes
|
Last Post Today, 12:32 AM |
Comment