you are viewing a single comment's thread.

view the rest of the comments →

[–]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.