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
Using a Displayed Moving Avg in a strategy
Collapse
X
-
Hello TradingGuy,
Displacement translates to a bars ago value. This is something that is just used visually for charts.
If an indicator is displaced by 2, this means the value from 2 bars ago is shown on the current bar and the value for the current bar hovers in the blank area to the right where no bars are showing.
So just add 2 to whatever bars ago value is being used.
For example to detect a crossabove from 3 bars to 2 bars ago:
Within the scope of the class:
private SMA smaFast;
private SMA smaSlow;
Within OnStateChange() when State is State.DataLoaded:
smaFast = SMA(7);
smaSlow = SMA(14);
In OnBarUpdate:
if (smaFast[3] < smaSlow[3] && smaFast[2] > smaSlow[2])
{
Print(Time[0].ToString() + " A cross has occurred 2 bars ago");
}
-
Using a Displayed Moving Avg in a strategy
Does anyone know how to use strategy builder for Ninja 8 to have a displaced moving average as the indicator in a simple buy sell crossover. I get it to work but the actual entries and reversals are all wrong. I have inputs for the period and displaced value so that I can optimize it if and when I get it to work correctly.
Basically the code reads as close crosses from below the EMA(Period, displaced value) go long and the reverse for the short.
The strategy works if I just use the EMA or other Moving average, but the displaced line works so much better when I trade it manually off of the actual displaced line.
Once I get this basic part correct, I can then add in the other noise filters.
Any help would be appreciated.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,279 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
||
Started by WHICKED, Today, 12:45 PM
|
2 responses
19 views
0 likes
|
Last Post
by WHICKED
Today, 03:36 PM
|
||
Started by Tim-c, Today, 02:10 PM
|
1 response
9 views
0 likes
|
Last Post Today, 02:52 PM | ||
Started by Taddypole, Today, 02:47 PM
|
0 responses
5 views
0 likes
|
Last Post
by Taddypole
Today, 02:47 PM
|
||
Started by chbruno, 04-24-2024, 04:10 PM
|
4 responses
52 views
0 likes
|
Last Post
by chbruno
Today, 02:38 PM
|
Leave a comment: