Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code to add preceding candle as a condition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    152 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    305 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    345 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    176 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X