Algorithmic Peak detector

Discussion in 'Technical Analysis' started by cfd_trader, Jun 28, 2011.

  1. I've been using for the last few weeks a fairly known setup/system which I have slightly modified to fit my requirements (intraday - as in intra half hour :D - index futures/cfd trading), and so far so good, that one seems to provide a real tangible edge, though I still need to improve on trade/risk/money management, eg a staged exit would probably yield even better results.

    Anyhow, I have developed my own set of software tools (and market data) over the last couple of years and would like to backtest this setup under various market conditions to see how bad results can get - which they'll probably get at some point, let there be no doubt.:p

    However what I'm missing at this point is a good, efficient but not necessarily super speedy (accuracy being more important than speed here) "peak detector" algorithm, ie a software routine that's able to identify swing hi/swing lo sequences among a time series data set (cfd/futures data stream).

    Might sound easy, like duh just look for the Max/min value within a period, but in reality it's NOT. Noise, cycles, erratic behaviour of prices, etc... which are extremely well handled by our brain are but easy to detect and filter out.

    In fact, the mere definition of what constitutes a valid/pertinent swing hi/lo is a task of its own already...

    Has anyone looked into this, or better yet already using such a software algorithm? Which parameters do you specify to adjust the detection and filtering of data ? How does it work, on what platform ? Etc...

    TIA. :)
  2. You buy 10,000 lots at the market and what is left is a pointy bottom. You sell 10,000 lots at the market and what's left is a peak.

    The peak detection occurs one millisecond before I push the buy or sell button.:eek:
  3. How soon after the peak/valley do you need to have identified that was in-fact a peak/valley?
  4. frostengine, at this point I'm just planning for the backtest of that apparently successful setup, therefore I don't need to be picky on the algorithm "reactivity" in terms of immediately identifying a peak/valley.

    Though obviously to apply that setup in live trading this will have to be determined within a very few bars if I'm to stand a chance to ever enter a trade before the setup is over. ^^ More seriously, for now I'll let my eyes be the judge, until I found an accurate and smart algo to do that work for me.

    In fact I suppose I need to define at least 2 parameters :

    - the relative amplitude of a "peak" or "valley" wrt to surrounding bars
    - the window (ie number of bars before and after) within which a max/min may be declared a valid peak/valley

    Probably need to define other factors, maybe "excluding" ones (filter), not sure which one though. All of this to make sure the peak/valley is clearly identified and that a visual inspection would confirm it.

    Just for reference I mainly use 2mns and 15mns bar/candle charts.

    I guess an image is worth etc etc... here's a sample (daily) bar chart found on the net :


    Matter of fact, if I were to ask 10 different people here to list what they consider as peaks and valleys on this chart I'm pretty certain I would get 10 different responses, wouldn't I...?:p

    P.S. Incidentally there's apparently (one indicator missing so can't be sure) at least one occurence of that setup on this chart, and guess what ? Worked pretty well ! :)