Thanks in advance.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Code to add preceding candle as a condition
Collapse
X
-
Code to add preceding candle as a condition
I'm trying to create a pullback/breakout indicator. I have correctly defined a PullbackCandle with a bool function. I want to now define the BreakoutCandle as the candle that makes a new high vs the previous candle only if that previous candle is also a PullbackCandle (that's critical). When I try to use a bool function with something like this: bool isBreakoutCandle = isPullback[1] && High[0] > High[1], I get a "cannot apply indexing with [] to an expression of type bool. What would be a work around that?
Thanks in advance.Tags: None
-
Hello snoinvest,
Thank you for your post.
Is isPullback a bool? This would likely be why you are getting the error if this is the case, bools can only contain true or false values. Indexing [] can only be applied to things like series.
You could instead define it as a custom Series<bool> which would hold a collection of true/false values. Then you could store a true or false value for every bar, and access it via indexing i.e. isPullback[0] for the current bar processing, isPullback[1] for the previous bar, etc.
Please let us know if you have any further questions.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
557 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment