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
Logic for distance between major emas greater then in ticks
Collapse
X
-
Can you please also loot at other similar challenge i have with calculating difference between EMA and Low/High
https://ninjatrader.com/support/foru...a-bar-is-wrong
-
Hi, Will I need to create a double for opposite to calculate for longs/shorts?
double EmaDiff = Math.Abs(EMA600[0] - slowEMA[0]);
Leave a comment:
-
Originally posted by tkaboris View PostHi in my strategy settings i have
DistanceBEMAs = 20;
and in logic I want to specify to open order only if distance between EMAs are greater in ticks . Is this the correct logic?
slowEMA[0] > EMA600[0] + DistanceBEMAs * TickSize)
You should always take into account that the either of the EMAs
could be higher or lower than the other.
Try this,
Add this code as a new Class variable:
Code:// calculate constant value private double EmaDistance;
Code:// one time calculation EmaDistance = DistanceBEMAs * TickSize;
Code:double EmaDiff = Math.Abs(slowEMA[0] - EMA600[0]); if (EmaDiff > EmaDistance) Print("Distance is good"); else Print("Distance is no good");
Last edited by bltdavid; 02-01-2023, 11:04 PM.
Leave a comment:
-
Hello, thanks for writing in. The best way to verify your code is to use Print so you can see the data that your strategy is producing e.g.
Code:if(slowEMA[0] > EMA600[0] + DistanceBEMAs * TickSize) { Print("EMA condition true " + Time[0] + " " + slowEMA[0] + " " + EMA600[0] + DistanceBEMAs * TickSize); //submit order }
This way you can see exactly the condition you have set up and make adjustments if necessary.
Leave a comment:
-
Logic for distance between major emas greater then in ticks
Hi in my strategy settings i have
DistanceBEMAs = 20;
and in logic I want to specify to open order only if distance between EMAs are greater in ticks . Is this the correct logic?
slowEMA[0] > EMA600[0] + DistanceBEMAs * TickSize)Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ClauTrade, Today, 12:39 PM
|
0 responses
2 views
0 likes
|
Last Post
![]()
by ClauTrade
Today, 12:39 PM
|
||
Started by ClauTrade, Today, 12:15 PM
|
0 responses
5 views
0 likes
|
Last Post
![]()
by ClauTrade
Today, 12:15 PM
|
||
Started by Snowdogg, Today, 11:39 AM
|
0 responses
3 views
0 likes
|
Last Post
![]()
by Snowdogg
Today, 11:39 AM
|
||
Started by SampaioCabezas, Yesterday, 01:58 PM
|
2 responses
21 views
0 likes
|
Last Post
![]() |
||
Started by ny10013, Today, 06:45 AM
|
2 responses
18 views
0 likes
|
Last Post
![]()
by ny10013
Today, 11:05 AM
|
Leave a comment: