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 Hwop38, 05-04-2026, 07:02 PM
|
0 responses
152 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
305 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
244 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
345 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
176 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment