Announcement
Collapse
No announcement yet.
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.
-
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.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
52 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
130 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
70 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
44 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment