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
SMA Distance in ATS
Collapse
X
-
SMA Distance in ATS
Hey guys :-) I have a question: If I add a SMA-Indicator to my chart, I have the choice to push him a few steps to the right with an option named "distance" (see on picture). I would like to use this option for an automated trading strategy, but can't find the parameter in SMA source code. So I guess it is only an optical manipulation, right? How can i implement this function in a strategy? I have tried this: ....&& (CrossAbove(Close, SMA1, 1))) --->>> ......&& (CrossAbove(Close[0], SMA1[4], 1))), but of course it doesn't work :-) I'm newbee in programming NT.1 PhotoTags: None
-
Hello Uwe1981,
Thank you for your reply.
You're right that displacement or distance for an indicator applied to a chart is strictly a visual manipulation. You can access these values in a strategy by using BarsAgo values, so SMA1[4] would give you the value of the SMA at the fifth bar on the chart. You can also apply a separate indicator with that displacement to the chart with the strategy to visually see it while you're running the strategy.
What condition are you trying to create? Just if the SMA of the 5th bar crosses the close price?
Thanks in advance; I look forward to assisting you further.Kate W.NinjaTrader Customer Service
-
Hello Kate,
thank you for your answer. Yes, at this moment I need to realize a crossover condition with Close[0] to SMA[x]. Of course, I could generate a separate indicator but is that necessary for such a simple condition? SMA1[4] works in a "higher as/lower as/equal"-condition without any problems, but unfortunately it does not work for crossover conditions. If I write "..&& (CrossAbove(Close[0], SMA1[4], 1)))" it generate an error while compiling. Maybe I do something wrong...? Greetings from Cracow :-)
Comment
-
Hello Uwe1981,
Thank you for your reply.
In this case you'd want to use something like this rather than CrossAbove():
&& (Close[0] > SMA1[4])
This is because CrossAbove is really for when you want to know if the cross occurred any time during a range of bars. You can find more about CrossAbove ()in our help guide here:
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Hello Uwe1981,
Thank you for your reply.
You could do something like this to only trigger if the price crossed over the SMA since the previous bar:
&& (Close[0] > SMA1[4])
&& (Close[1] < SMA1[4])
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Dr Kerry, Today, 02:03 AM
|
0 responses
2 views
0 likes
|
Last Post
by Dr Kerry
Today, 02:03 AM
|
||
Started by AndriXF7, 12-06-2023, 10:09 AM
|
5 responses
161 views
1 like
|
Last Post
by Lunorri
Today, 01:56 AM
|
||
Started by rosa2013, Today, 01:47 AM
|
0 responses
1 view
0 likes
|
Last Post
by rosa2013
Today, 01:47 AM
|
||
Started by owenany, Today, 01:25 AM
|
0 responses
1 view
0 likes
|
Last Post
by owenany
Today, 01:25 AM
|
||
Started by BigRay, 04-07-2023, 05:41 PM
|
2 responses
659 views
1 like
|
Last Post
by 2inthebush
Today, 01:10 AM
|
Comment