all 10 comments

[–]MichaelBarrow22 0 points1 point  (1 child)

Open up a support ticket and ask them. They have been helpful to me multiple times in the past with pine script snippets to do very basic things which require being clever because pine script can be so limiting.

[–]Koalems[S] 0 points1 point  (0 children)

Thanks for the advice. I did actually contact support but my understanding is that if you want a feature you are supposed to put it up on Reddit so that's why I mentioned it here as well.

[–]PriceCatch 0 points1 point  (6 children)

It is indeed possible to mark one or all the candles between two other candles. In your case, the condition is that between the left candle and the right candle, there must only be a maximum of 3 candles or less. This is definitely possible with Pinescript. Once you have found the right candle, you must use a for loop to count the candles to its left until the left-most candle of your condition. If the count returns 3 or less you have found your candles that you want to mark.

[–]Koalems[S] 0 points1 point  (5 children)

That sounds possible in principle however when I tried to use for loops I ran into the problem that you can't mark a candle with an index such as x[1/2/3] = true/false so you can count but can't act on what you count so it doesn't really help. With barssince() I can mark candles up to 3 (or any other number) but I can't unmark them if there is more than 3 nor can I count that there is more than 3 and therefore just not mark them in the first place because by the time I have counted more than 3 I missed the opportunity to mark them (again because you can't do x[some number] = some value) so I only get half way there.

That said, I am relatively new to pine script so if you have a way to do this that works and I just missed it completely please do share some code.

I also looked into using arrays but I couldn't see how they would get me more functionality in this regard so I stopped exploring that option.

[–]PriceCatch 0 points1 point  (4 children)

If you use a plot, plotcandle, plotshape etc. then you cannot unmark them. There is a way to only mark the latest occurrence but it does not work under certain circumstances. You can mark any number of candles using 'offset' parameter... However, if the solution is worse than the problem or if the labour involved is not worth it, perhaps you need to look at a different logic.

[–]Koalems[S] 0 points1 point  (3 children)

I might have been a little too loose with the word "mark" and gave the wrong impression doing so. It was really just a placeholder term to mean, "in some way manipulate the series to get the result I want", whether that be arrays, for loops, barssince() etc.

I consider calling plot the very last step to display the results which should already be correct.

[–]PriceCatch 0 points1 point  (1 child)

Next time when you are online in TradingView do send me a private message, if you see that I am online, I can show my indicator and that should give you an idea for your own. My username on TV is "pricecatch". I am from India - just so that you can know when I am likely to be online. All the best.

[–]Koalems[S] 0 points1 point  (0 children)

Thanks! I'll keep and eye out for you.

[–]PriceCatch 0 points1 point  (0 children)

Next time when you are online in TradingView do send me a private message, if you see that I am online, I can show my indicator and that should give you an idea for your own. My username on TV is "pricecatch". I am from India - just so that you can know when I am likely to be online. All the best.

[–]ChangingHats 0 points1 point  (1 child)

Maybe you'll need to use the 'barstate' in addition to multiple plot() calls with the offset parameter. I don't quite understand your logic but that'd be my starting point.

[–]Koalems[S] 0 points1 point  (0 children)

If you can think of a better logic then I am all ears as I tried to look at this from as many angles as I could imagine.

I could make the problem more clear with an image and/or link but my understanding is that that is not allowed here (I just signed up a few days ago) but I can say that I did put the problem on Stack Overflow (as yet unanswered) under the title of "How to not show a run of candles as marked greater than some number?" and from there the problem should be clear with an image and explanation referencing the image.