ET News & Sponsor Info
General Topics
Markets
Technical Topics
Brokerage Firms
Tools of the Trade
Trading for a Living
Community Lounge
Site Support

# Math Question - Peak Detection Algorithm

Discussion in 'Technical Analysis' started by ET151, Dec 11, 2010.

1. ### ET151

I have an indicator that oscillates between 0 and 1. It looks like a stochastic oscillator and the signal has a variable frequency. It's smooth most of the time, and the peaks are usually curved or sharp / pointed. I want to identify the locations of the peaks. One way to do this is by keeping track of the min / max points and then calling the peak the highest point once the signal deviates away from that point by some margin. Then after the highest point is called, reset the min/max points to the value of the current point. However, does anyone know of a simpler or more robust way? I could code this up myself, but I figure there's a better / more computationally efficient way to do it than what I have just described. I figure this must come up a lot in technical analysis / automated trading.

2. ### killthesunshine

jesus just learn to trade

3. ### intradaybill

Then the min is 0+ and the max is 1-.

4. ### rosy2

for inflection points you can check for zero slope or do diffs to get sign changes.

<code>
public static List<double> ixt(List<double> ii){
double[] iii = new double[ii.Count - 1];
List<double> iiii = new List<double>();

for (int i = 1; i < ii.Count; i++){
iii[i - 1] = ii - ii[i - 1];
}
for (int i = 0; i < iii.Length - 1; i++){
double x = iii * iii[i + 1];

if (i>0 && x<0)
iiii.Add(ii[i + 1]);
}
return iiii;
}
</code>

5. ### ET151

Yes, checking for change in slope is one way to do it and maybe the best if there's not much noise. I've also considered taking the difference of two moving averages, longer and shorter. There's always going to be a tradeoff between lag and accuracy with any approach. But I think something more statistically-based would provide a better solution (minimum lag with high accuracy).

7. ### JuniorCTA

if you are trying to detect the curve or sharp; why don't you look for whenever f'(x) = 0 or f'(x)=does not exist. change of signs is good too but it would lag a little considering you would have to wait for the current interval to end.

8. ### murray t turtle

=====================

Yes, there is a simply way, its battle tested also;
200 day moving average, with some shorter- ''sharp pointed'' moving averages[hint =less comissions/slippage with longer moving averages]
Speaking of yearly patterns-Merry Christmas/hanukkah/ thanksgiving Cool

9. ### boneET Sponsor

Nobody wants to mention the most applicable and profitable variable: the timeframe (s) you choose to sample.

This has been done ad nauseum - look at timeframes for real traction.

10. ### Stoxtrader

The no-lag solution is to use a filter. You could either try low-pass, band-pass, high-pass filters and see what works best. Or do a spectral analysis and see what frequency/frequencies the peaks occur at... watch those frequencies for any value above a certain threshold.

#10     Dec 13, 2010
ET IS FREE BECAUSE OF THE FINANCIAL SUPPORT FROM THESE COMPANIES:
 AMarkets Forex, Commodities & CFDs AMP Global Clearing Futures and FX Trading Earn2Trade Trading Education and Funding Challenge efutures Futures & Options Trading GFF Brokers Low-Cost Futures Brokerage IC Markets True ECN for FX and CFDs Jigsaw Trading Advanced Trading Tools KJ Trading Systems Trader Education Services Lightspeed Equities & Options Trading MetaTrader 5 Institutional Multi-Asset Platform MotiveWave Full-Featured Trading Software NinjaTrader Trading Software & Brokerage Optimus Futures Futures Trading Platforms and Order Routing Option Workshop Option Analysis Software Rithmic Futures Trade Execution Platform SpreadProfessor Spread Trading Instruction TD Ameritrade Introducing 24 hour trading, 5 days a week TopstepTrader We Fund Traders TradersStudio System Development Platform Trading Technologies Trading Software Provider Tradovate Commision-Free Futures Trading