Reputation: 15
I searched a lot for an answer to the problem but I was not able to find one.
My problem (just an example, many similar ones exist): I need to identify the highest volume bar in a specific past quarter and plot a (custom) indicator starting from that specific bar to the last bar.
No problem to identify the bar and to calculate the indicator starting from it.
The problem is related to the plotting. Why: I know the highest volume bar (date) only after the analysis of all quarter's bars (at least based on my knowledge of Pine); so when the interesting bar/date is known, I should plot in the past, but that is not possible (at least with the 'plot' function).
Questions:
What I'm thinking to do if no other solution exists is: A. Identify the interesting bar / date analyzing all the quarter (I repeat, 'quarter' is just an example, could be year, month, week, ...) B. Start plotting (with the 'plot' function and the 'a ? b:c' operator) the custom indicator at the end of the quarter C. Putting on that 'starting' bar a label with the real starting date (the 'interesting' date)
Thanks for any help. Cheers from Italy
Upvotes: 0
Views: 502
Reputation: 21342
Your script is executed on each bar. So, you cannot really go back and plot something with the plot()
functions.
Your only option is using line
but that has its own limitations as you mentioned.
Another workaround would be, you do your analysis and identify the start bar index. Then use this as an input and only plot if bar_index > bar_index_start
. This of course cannot be automated so someone has to do the analysis first and then input that to the main script.
Upvotes: 0