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 Allwest, Today, 10:25 PM
|
1 response
9 views
0 likes
|
Last Post
by gaz0001
Today, 10:36 PM
|
||
Started by Mindset, Today, 10:31 PM
|
0 responses
9 views
0 likes
|
Last Post
by Mindset
Today, 10:31 PM
|
||
Started by sevensa, 03-14-2024, 10:15 PM
|
3 responses
27 views
0 likes
|
Last Post
by sevensa
Today, 10:19 PM
|
||
Started by bertochi, 04-16-2020, 12:15 PM
|
30 responses
1,060 views
2 likes
|
Last Post Today, 09:36 PM | ||
Started by Lumbeezl, 01-11-2022, 06:50 PM
|
28 responses
760 views
1 like
|
Last Post Today, 09:23 PM |
Comment