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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    24 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    14 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    9 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    10 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    17 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X