Thanks for your help, best regards.
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
Difference between 2 EMA > 50...
Collapse
X
-
Difference between 2 EMA > 50...
Hello, I'm trying to add a simple condition to my strategy. I want to have a difference between the EMA 100 and the EMA 300 at least 50 points. That should be simple..but I don't manage to do it :-(
Thanks for your help, best regards.Tags: None
-
Hello TraderFred,
Thank you for the post.
Are you trying to use the strategy builder or manually code the strategy?
To find the difference you would subtract one from the other. If you then wanted that reported in points you would need to use math to convert the price difference to points.
A very simple example would be using Ticks instead and that would look like the following:
Code:double tickDifference = (EMA(100)[0] - EMA(300)[0]) / TickSize;
JesseNinjaTrader Customer Service
-
-
Hello TraderFred,
With the builder you could do the subtraction however you would not be able to convert the resulting value to ticks or anything else. The best way to achieve this in the builder would be to make a complimentary indicator that goes with the strategy. The indicator could use the code shown in post 2 and Plot that result. The strategy could then read the indicators value to see what the value in ticks was.
Please see the following for a sample of adding a Plot, you can alternatively just use the indicator wizard in the NinjaScript editor to generate a new indicator and add a Plot during that process.
Once you have a indicator generated and have a plot you could use the following from OnBarUpdate:
Code:double tickDifference = (EMA(100)[0] - EMA(300)[0]) / TickSize; Value[0] = tickDifference;
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johnMoss, 03-04-2024, 01:53 PM
|
3 responses
46 views
0 likes
|
Last Post
by AndyM
Today, 06:13 PM
|
||
Started by algospoke, Today, 06:01 PM
|
0 responses
8 views
0 likes
|
Last Post
by algospoke
Today, 06:01 PM
|
||
Started by cre8able, Today, 05:53 PM
|
0 responses
8 views
0 likes
|
Last Post
by cre8able
Today, 05:53 PM
|
||
Started by Wessel, 03-23-2024, 02:37 PM
|
3 responses
24 views
0 likes
|
Last Post Today, 04:58 PM | ||
Started by martini, Yesterday, 04:45 PM
|
4 responses
32 views
0 likes
|
Last Post
by martini
Today, 04:48 PM
|
Comment