TradingView
twingall
2023年3月27日晚上10點07分

Pivot Highs&lows: Short/Medium/Long-term + Spikeyness Filter 

E-mini S&P 500 FuturesCME

描述

Shows Pivot Highs & Lows defined or 'Graded' on a fractal basis: Short-term, medium-term and long-term. Also applies 'Spikeyness' condition by default to filter-out weak/rounded pivots

ES1! 4hr chart (CME) shown above, with lookback = 15; clearly identifying the major highs & lows on the basis of how they are fractally 'nested' within lesser Pivots.
-- in the above chart Short term pivot highs (STH) are simply represented by green 'ʌ', and short-term pivot lows (STL) are simply represented by orange 'v'.

//Basics: (as applying to pivot highs, the following is reversed for pivot lows)
-Short term highs (STH) are simple pivot highs, albeit refined from standard with the 'spikeyness' filter.
-Medium-term highs (MTH) are defined as having a lower STH on either side of them.
-Long-term highs (LTH) are defined as having a lower MTH on either side of them.

//Purpose:
-Education: Quick and easy visualization of the strength or importance of a pivot high or low; a way of grading them based on their larger context.
-Backtesting: use in combination with other trading methods when backtesting to see the relative significance and price sensitivity of LTHs/LTLs compared to lower grade highs and lows.

//Settings:
-Choose Pivot lookback/lookforward bars: One setting, the basis from which all further pivot calculations are done.
-Toggle on/off 'Spikeyness' condition to filter-out weak/rounded/unimpressive pivot highs or lows (default is ON).
-Toggle on/off each of STH, MTH, LTH, STL, MTL, LTL; and choose label text-styles/colors/sizes independently.
-Set text Vertically, horizonally, or simply use 'ʌ' or 'v' symbols if you want to declutter your chart.

//Usage notes:
-Pivots take time to print (lookback bars must have elapsed before confirmation). Fractally nested pivots as here (i.e. a LTH), take even longer to print/confirm, so please be patient.
-Works across timeframes & Assets. Different timeframes may require slightly tweaked lookback/forward settings for optimal use; default is 15 bars.

Example usage with just symbolic labels short-term, med-term, long-term with 1x, 2x and 3x ʌ/v respectively:

發布通知

-Added Alert conditions. Set alerts by clicking three dots on indicator status line. 6 alerts: Crossover latest LTH, MTH or STH. Crossunder latest LTL, MTL or STL.
-Added Table showing most recent Short, Med & Long-term pivot highs and lows. User can toggle on/off the display table.

發布通知

-Added table text color: Users who prefer black chart backgrounds can edit text color.

發布通知

-Added optional Lines (default is off). Each of STH STL MTH MTL LTH LTL can have lines independently toggled on/off.
-Lines always terminate when crossed by price. Line color = respective text color. Line style (dotted, solid, dashed) is set universally.
Example Chart with All lines toggled on, ES1! 4hr chart:

發布通知

-Cleaned up code and comments in code.
-Credit to @Bjorgum for the extendAndRemove() function used for self-terminating lines.

發布通知

-Added 'Wait one bar' condition to avoid repainting; Default is toggled ON.
評論
GamerDante
Bro good job! Top G!
twingall
@GamerDante, thanks!
QSInvestments
This is a great idea. I love the functionality of it. I also like the options to personalize it with your own colors, font size, etc. But I'm afraid that it misses out on pointing to the obvious highs and lows. I'm seeing glaring MTH/Ls being ignored. And how can it be on a HTF like the MONTHLY without pointing out a single LTH?
twingall
@QSInvestments, thanks. First response would be to say that the terms ST/MT/LT are entirely relative on the chart timeframe. So if on monthly or even 3M chart, a LTH or LTL will only be defined once sufficient bars have elapsed to nest the LTH/LTL between MTH/MTL which themselves are between STH/STL; so you could be looking at years on a super High timeframe chart before getting confirmation. Also, it's not perfect, but perhaps mitigate any glaring MTH/Ls that don't print by removing spikiness index (or tweaking it); or by changing pivot length... If you have any more specific critique you can PM me and will see if i can work on a fix if there is one..cheers, T
marquism
When I replay this, the alerts don't appear until several, several candles later. Like over 40 :(
Can you please fix this?
twingall
@marquism, Alerts are working fine in realtime. On TradingView, server-side alerts only fire based on realtime data, they cannot be created in replay mode .
See this article by TradingView for more information (scroll to the bottom): How do I turn Bar Replay on?
CJMann
@twingall, First, thanks for sharing your great work! Quick question: I'm not sure I'm understanding your comment. I was just going back in "replay"mode to do some manual testing and the pivot identification doesn't come until several bars later...i.e. more than 10. Are you saying that it is different in real-time? Will the pivot identification come earlier? Or is the purpose of the script more for "education" as mentioned above and the script can't really be used as part of a trading /signalling strategy strategy. Would appreciate clarification? And in the meantime, will put it on my chart to see whaat happens in real-time.... thanks again!
twingall
@CJMann, thank you.. was just talking about alerts, all else should work in replay as it does in realtime
marquism
@twingall, @CJMann I think there's a misunderstanding. We know how to use replay lol. We're saying that the alerts are delayed by numerous bars. Is this supposed to alert when each spike appears? Or are these alerts supposed to occur when crossing a certain line if you turn on line in the settings? Also when you use replay, it's also delayed. But more importantly are the alerts.
twingall
@marquism, alerts are for cross above / below the most recent pivot high/low, be it ST/MT/LT. Alerts are not for pivot identification. Turning on/off line settings is just visual and will not affect alerts. I may add alerts for pivot identification, but they would always be delayed by the lookback input number of bars(pivot high /low is only confirmed & painted after lookback #bars have elapsed). hope this helps..
更多