Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
MAX of an indicator
Collapse
X
-
Happy Holidays All! Could someone please advise how to use the aforementioned syntax with NT8 indicator OrderFlowCumulativeDelta while using the BarsArray functionality, too?
Example: Lets say within a strategy set to OnBarUpdate I want to find if the current bar "[0]" is the "bar with the highest session delta over the last 10 bars," and I'm doing this across multiple timeframes (i.e. BarsArray[1], BarsArray[2], etc.)
If I were using the ATR indicator instead of OrderFlowCumulativeDelta, I completely understand this:
But I can't seem to find the right way to pass the below through the MAX() function and make it compile:Code:MAX(ATR(50), 10);
Thanks in advance for any response!Code:OrderFlowCumulativeDelta(BarsArray[1], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaHigh[0]
Comment
-
Hello jeh007258,
Thanks for your post and welcome to the NinjaTrader forums!
The MAX() requires a series as its input and also requires a bars ago as a starting point.
Reference: https://ninjatrader.com/support/help...aximum_max.htm
I think what you want is:
if (OrderFlowCumulativeDelta(BarsArray[1], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaHigh[0] > MAX(OrderFlowCumulativeDelta(BarsArray[1], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaHigh, 10)[1])
{
// do something
}
Note that I used MAX(....)[1] so that it pulls the max value from the 10 previous bars and then the if statement compares that to the current bar value[0] of the cumulative delta.
NOTE: I would suggest looking at calling the OrderFlowVWAP by reference instead of creating new copies on each call. Please check the second example here: https://ninjatrader.com/support/help...ive_delta2.htm That way you do not need to write as much and can eliminate the parameters. Using the example in your case your code would look more like:
if (cumulativeDelta.DeltaHigh[0] > MAX(cumulativeDelta.DeltaHigh, 10)[1])
{
// do something
}
which is much easier to read and less prone to errors.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
35 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
20 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
13 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
19 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
21 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment