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
-
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 rdtdale, Yesterday, 01:02 PM
|
2 responses
16 views
0 likes
|
Last Post
by rdtdale
Today, 07:54 AM
|
||
Started by TradeSaber, Today, 07:18 AM
|
0 responses
7 views
0 likes
|
Last Post
by TradeSaber
Today, 07:18 AM
|
||
Started by PaulMohn, Today, 05:00 AM
|
0 responses
10 views
0 likes
|
Last Post
by PaulMohn
Today, 05:00 AM
|
||
Started by ZenCortexAuCost, Today, 04:24 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 04:24 AM | ||
Started by ZenCortexAuCost, Today, 04:22 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 04:22 AM |
Leave a comment: