TradingView
Trendoscope
12 ноя 2022 г., 23:31

Next Pivot Projection [Trendoscope] 

Bitcoin / TetherUSBinance

Описание

Still experimental. Extending further on the divergence backtest results - in this script we try to project next 2 pivots (including one unconfirmed pivot)

🎲 Previous experiments
1. Divergence-Backtester
2. Divergence-Backtester-V2

🎲 Additions
  • Apart from collecting the stats on number of occurrences of HH, HL, LH, LL - this script also keeps track of average ratio for each levels and average bars.
  • Based on these data, we try to calculate the next pivot projections including possible bar and price.
  • Cloud covering the candles indicate historical levels of average HH, HL, LH, LL projections.


Hover on projection labels to find more details in tooltips.

🎲 Overall method in a nutshell


🎲 Going bit deeper
🎯 Unconfirmed Pivot and its projection - Last pivot of the zigzag is always unconfirmed. Meaning, it can potentially repaint based on further price movements. But, projection of the unconfirmed pivot will not change as it will be based on previous two pivots - both of which are confirmed.



🎯 Next Pivot Projection - Next pivot is projected based on last two pivots - which include last unconfirmed pivot. Hence, these projections can potentially repaint based on the last pivot repaint.



🎯 Historical projections displayed as cloud - Historical projection values are displayed as cloud around pivots.
A cloud above represents area from average lower high range to average higher high range. Cloud color is green if average ratio of pivot high is more than 1. Red Otherwise.
A cloud below represents area from average higher low range to average lower low range. Cloud color is red if average ratio of pivot high is more than 1. Green otherwise




Информация о релизе

Small update - cloud fill is based on the historical ratio of HH/LH and LL/HL instead of basing that on the average ratio. Average ratio can be misleading - it would have been nice to get the median instead. But, it is not easy to achieve this. Will keep trying to improve further ;)

Информация о релизе

Fixed a bug highlighted by @zeallot

The stats were adding once per bar. But, only need to add when there is pivot change.

Информация о релизе

Further corrections.

Информация о релизе

Added option to remove fills representing bullish and bearish sentiments
Комментарии
PineCoders
Scotty-Mac
This is awesome dude. Will be following this indicator for sure! Great job so far!
Trendoscope
@Scotty-Mac, thanks a lot :)
KioseffTrading
NO WAY man this is absolutely awesome haha!
Trendoscope
@KioseffTrading, thanks buddy. As always :)
saltuklev
Great work!
saltuklev
@HeWhoMustNotBeNamed Great work! As far as my tests %95+ percentages have great success rate. So how can I add an alert for over %95 percentage? I know it is open source but my knowledge is limited. And no alert sample to play..
Trendoscope
@saltuklev, I haven't added alerts. Can be tricky if you want to filter only based on certain percent. Will think about it.
dixitbig
@HeWhoMustNotBeNamed, great work wanna know more but am a newbie
Zeallot
@saltuklev, Adding alerts is difficult, but you could choose to only draw the projections which have reached a user-defined threshold fairly easily. First, define a new variable for this threshold:
- threshold = input.int(75, 'Probability Significance Threshold', minval = 1, maxval = 100, step = 5, group = 'Stats and Display')/100
Next, we want to modify the local variables hhLine, lhLine, hhLabel, lhLabel, llLine, hlLine, llLabel, and hlLabel. These can be found round lines 300, 315, 400, and 415 respectively. All we need to do it is add a condition that the percentage has reached our threshold. The adjusted code would be:
- hhLine := hhStats/tStats >= threshold ? line.new(x1, y1, hhX2, hhY2, xloc=xloc.bar_index, color=color.green, style=line.style_arrow_right) : na
- lhLine := lhStats/tStats >= threshold ? line.new(x1, y1, lhX2, lhY2, xloc=xloc.bar_index, color=color.lime, style=line.style_arrow_right) : na
- hhLabel := hhStats/tStats >= threshold ? label.new(hhX2, hhY2, str.tostring(hhY2)+ ' - ' +hhPercent, style=label.style_label_lower_left, color=color.new(color.green, 50), textcolor = color.white, size=size.small, tooltip=hhText) : na
- lhLabel := lhStats/tStats >= threshold ? label.new(lhX2, lhY2, str.tostring(lhY2)+ ' - ' +lhPercent, style=label.style_label_upper_left, color=color.new(color.lime, 50), textcolor = color.white, size=size.small, tooltip=lhText) : na
- llLine := llStats/tStats >= threshold ? line.new(x1, y1, llX2, llY2, xloc=xloc.bar_index, color=color.red, style=line.style_arrow_right) : na
- hlLine := hlStats/tStats >= threshold ? line.new(x1, y1, hlX2, hlY2, xloc=xloc.bar_index, color=color.orange, style=line.style_arrow_right) : na
- llLabel := llStats/tStats >= threshold ? label.new(llX2, llY2, str.tostring(llY2)+ ' - ' +llPercent, style=label.style_label_upper_left, color=color.new(color.red, 50), textcolor = color.white, size=size.small, tooltip=llText) : na
- hlLabel := hlStats/tStats >= threshold ? label.new(hlX2, hlY2, str.tostring(hlY2)+ ' - ' +hlPercent, style=label.style_label_lower_left, color=color.new(color.orange, 50), textcolor = color.white, size=size.small, tooltip=hlText) : na

This is just quick and dirty way to eliminate some of the clutter you might have and draw your attention to those projections which matter to you.

Note: if you would like to lose the yellow line which is essentially a weighted average of projections, simply comment out the tLabel and tLine variables with //
Ещё