alexgrover

Peak/Valley Estimation

Early Signal

Estimating the Peaks and Valleys or extrema of the price is one of the best way to catch up early movements of a trend. Of course there is no perfect way to do so, if we want a perfect estimation of peaks and valleys then we must use a non causal indicator (repainting), if we want a causal indicator (non repainting) then we will need to tradeoff accuracy for allowing our indicator to be causal, its always a matter of tradeoff at the end when trying to have a desired effect (smoothness/lag for filters).Our indicator is causal, it wont repaint but the accuracy will depend on various parameters.

In order to detect peaks and valleys in a certain period we must detrend the price, this mean subtracting it by its moving average. We take the absolute value of this result and we filter it with a local linear regression (LSMA) in order to eliminate noise, then we make the assumption that the highest of our result is or a peak or a valley of the price, so we divide our detrended calculation by its highest and we get a scaled result. Lets call this final result the peak index.

Parameters

There are 3 parameters in this indicator, a length parameter who control the period of the highest mentioned above, a smooth parameter who smooth our detrended price, and finally a mod parameter who select the trigger method for estimating a peak/valley.

Here are how mods work :

  • mod = 1 : when the peak index is equal to 1 and the previous value is not equal to 1 then we have a peak/valley. Its the fastest of the 3 mods but the one with less accuracy.
  • mod = 2 : when the peak index crossunder 0.8 then we have a peak/valley. This method is more robust but slower than the previous one.
  • mod = 3 : when the peak index is not equal to 1 and the previous peak index is equal to 1 then we have a peak/valley. Its an average of the precedents mod in term of speed and accuracy.

Lower length values tend to estimate the peak/valley of short periods of time but can also lead to the reverse desired effect (breakouts signals). Smoothing is important since it reduce the number of noise in our calculation and therefore help to get better results, its a parameter that should be high, sometimes higher than length if this one is low.


Estimation of medium terms peaks/valleys with length and smooth parameter both period 100 and mod = 3


Estimation peaks in palladium way to early, an example of bad accuracy. Such behaviour can be fixed with a change in the parameters.

Complementarity With Classics Indicators

As i said before its always a matter of tradeoff, here we get faster signals but we loose in accuracy, at the contrary classics indicators often have slower signals but with more accuracy. Mixing both of them can provide additional robustness in a strategy, lets take back our palladium case, using mod 3 could have been better, but its still not optimal, so lets use a classic indicator such as a moving average of period 200, our conditions are :

  • Long when our peak/valley estimator estimated a valley and the price crossover our moving average.
  • Short when our peak/valley estimator estimated a peak and the price crossunder our moving average.

here is an exemple of such signal :

We balanced our tradeoff in a way to fix both methods problems, of course its still not a perfect fix but it provide more robustness.

Other Uses

The indicator can also be used only as an order closing indicator, its safer than taking a position based on its estimation. The indicator can also give a use to the peak index used in the calculation as a trend strength indicator.


Values below 0.5 indicate a ranging market while values over 0.5 indicate a trending market.Since its a scaled measure you can use it a smoothing constant in a adaptive filter.

Conclusions

I showed how to estimate peaks and valleys and how to use such information in order to make better decision when using classical indicators, of course at the end nothing is perfect and considering the non stationarity of the markets the parameters efficiency could change drastically.

For any questions/demands feel free to pm me, i would be happy to help you

Remove from Favorite Scripts Add to Favorite Scripts
You can check my indicator papers here : https://figshare.com/authors/Alex_Pierrefeu/7339466
Hi alexgrover,
I really do enjoy your work and I always check to see what’s new and see if anything new the unlimited ways it can be used. Therefore, I wondering if the Peak/Valley Estimation indicator could be used for future forecast of when to buy/sell and how?
Thank you again
+1 Reply
alexgrover aaahopper
@aaahopper, Hi aaahopper, the main indicator only give information about the probable direction the market will follow but not how it will do it :)
Reply
aaahopper alexgrover
@alexgrover, Thank you for your reply and clarification.
Reply
Detail explanation, looking forward to seeing you create more predictive indicator, thank you =D
+1 Reply
Great structure and explanation.
+1 Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Charting Solutions Help Center Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing TradingView Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out