Thanks
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
Displaced MA in strategy builder
Collapse
X
-
Displaced MA in strategy builder
How do you displace a MA to the left in strategy builder? I use it on an indicator and it would be a signal line. When it crosses above/below the other MA it paints the bar a specific color. I've got that part but am not successful in the first.
ThanksTags: None
-
Hello dedouglas,
Thank you for the question.
In NinjaScript there is no concept of "displacement" you would instead use the BarsAgo concept to reference data from other bars. For example, if you wanted to compare an MA against its self for a different bar value, you would use a BarsAgo of 1 or the number of bars you wanted ago.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Does this work on the cross above/below? I couldn't get my bars to paint until I switch condition to greater then. It was coloring them a bar or two late also and a few in a row until filtered out by other conditions. My goal is to paint the one bar a certain color when the signal line crosses above/below the other. Its an sma of the same period, but I want one offset to the left 1 bar. The input series isn't price but another indicator value if that makes a difference.
Thanks
Comment
-
Hello dedouglas,
The Cross above and below use a Lookback period which is how they would compare crossings. I see you noted you wanted to compare the same SMA of the same period, just offset by 1 bar. In a chart you can do this manually using the Displacement property of the indicator, however, in NinjaSript there is no concept of simply moving the values over. Displacement is just a visual change which moves the existing values in the direction you specified by that number of bars, the values are still all identical and still apply to the same bars they originally did. In NinjaScript you could instead use 1 BarsAgo in this situation, you could compare the SMA against the SMA of 1 bar ago to see fi there was a crossing.
When configuring the condition, you would enter 1 BarsAgo when configuring the first or second indicator to get the value of 1 bars ago for comparison.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
Hello NTbrass,
You can use the BarsAgo field to denote what data is used for each indicator, the left and right sides control properties for each indicator.
For the SMA of the same period you would likely need to use greater/lesser here to see any change in condition, the crossabove/below would be better used in a situation where you have some spans of time between crossings such as two different period SMA's or a fast/slow. You can see an example of this in the SampleMACrossOver strategy that comes with the platform however that is manually coded. You can do a View Code from the builder and then compare that against the sample to see if you are doing a similar condition or logic though.
As a side note here is a link to our public strategy builder webinar that goes over the condition builder: https://youtu.be/HCyt90GAs9k
Here is an image of a cross above condition between two smas, as noted you would likely need to use two different periods instead of bars ago here to see something similar to the SampleMACrossOver.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by junkone, 04-21-2024, 07:17 AM
|
10 responses
148 views
0 likes
|
Last Post Today, 09:03 AM | ||
Started by tsantospinto, 04-12-2024, 07:04 PM
|
6 responses
100 views
0 likes
|
Last Post
by tsantospinto
Today, 08:57 AM
|
||
Started by rocketman7, Today, 02:12 AM
|
5 responses
26 views
0 likes
|
Last Post Today, 08:56 AM | ||
Started by ZenCortexReal, Today, 08:54 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 08:54 AM | ||
Started by ZenCortexReal, Today, 08:52 AM
|
0 responses
0 views
0 likes
|
Last Post Today, 08:52 AM |
Comment