The details for comparing values in a multi-time script can be found here: http://www.ninjatrader-support.com/H...ameInstruments
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Indicator
Collapse
X
-
Hi ryebank,
To clarify, this is now on a single series (same time frame)?
Is this an "if" statement? Something like...
What leads you to believe it's missed when they are the same? Keep in mind that may be a somewhat rare occurrence for them to exactly equal one another.Code:if (SMA(Close,8)[0] >= SMA(Close,14)[0]) do something;
TimNinjaTrader Customer Service
Comment
-
hi
Yes single time frame.
An alert is generated if certain conditions are meet on bar[0] and one of these constraints is that SMA(Close,8)[0] is greater than or egual to SMA(Close,14)[0] - on all occasions where SMA(Close,8)[0] = 1.5362 and SMA(Close,14)[0] = 1.5362 it fails the test even though it passes all other constraints
Comment
-
Hi ryebank,
Try testing just the SMA condition by itself, to be sure what is truly happening, I tried the following, and the condition was satisfied several times.
I tried this and was able to get several instances (on a 5min ES chart dating back several months)
Code:if (SMA(Close,8)[0] == SMA(Close,14)[0]) { Print("Yes"); DrawVerticalLine("tag" + CurrentBar, 0, Color.Magenta, DashStyle.Solid, 4); }TimNinjaTrader Customer Service
Comment
-
ok
i've run some tests and can see that if i use '<' then it passes so that implies that the value of SMA 8 is lower that SMA 14 but in the data box it says they are the same
How do i find out what the exact values of the SMA's are if they are not the same s in the data box
Comment
-
Hi ryebank,
You can Print the values, for example:
More in on Print()'s at: http://www.ninjatrader.com/support/f...ead.php?t=3418Code:if (CurrentBar<15) return; if (SMA(Close,8)[0] == SMA(Close,14)[0]) { Print("Yes"); Print(SMA(Close,8)[0]); Print(SMA(Close,14)[0]); DrawVerticalLine("tag" + CurrentBar, 0, Color.Magenta, DashStyle.Solid, 4); }
Gain does not provide Historical daily data: http://www.ninjatrader-support.com/H...HistoricalData
As a worksaround, you can try 1440 Minutes bars.TimNinjaTrader Customer Service
Comment
-
Mta
Thanks for all the info, but i'm struggling with referencing data form a daily chart to compare that with data from a 5/15/60 minute chart
What i'm trying to achieve is this
protected override void OnBarUpdate()
{
if (CurrentBar < 1) return;
if (EMA(Close,8)[0] > EMA(Close,14)[0] && (make the same comparison on the daily chart) || (EMA(Close,8)[0] < EMA(Close,14)[0] && (make the same comparison on the daily chart)
do something
}
}
Comment
-
Hello ryebank,
Please not that multi time frame indicators are only available in version 7.
You'll have to look at sampleMultiTimeFrame. Click Tools > Edit NinjaScript > strategy and open this file.
Documentation is available here.
Once you've added the daily series in the Initialize, its close value is then accessed with Closes[1]
Example:
if (EMA(Closes[1], 8)[0] > EMA(Closes[1],14)[0] )Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
580 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
335 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
102 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment