Calculating the defintion of a "long" body

Discussion in 'Automated Trading' started by fandelem, Sep 20, 2005.

  1. Has anyone had any experience programming candlesticks into their automated trading strategy? If so, I would love to hear if you have customized-per-ticker a fixed "if abs(open-close) > 5 then longbody=true" style or you have come up with a formula where you do not need to use constant values?

    it's so easy to look at a chart and visually depict, but to tell a computer program how to visually depict, seems rather time-consuming.

    i have a few theories i am going to start coding tonight in my backtesting unit that i will share if others decide to share.
  2. kww


    I don't do automatic trading but I've coded candlesticks for backtesting. For defining a long body, it doesn't make sense to me to use an absolute value because you're ignoring differing volatilities. A "long" candle for one stock may be a relatively "short" candle for another stock.

    I define "long" by percentile ranking over a defined period. For example: a candle is long if it ranks in the top 20% of candle lengths over the past 60 trading days. You can obviously tweak these parameters to suit your purpose.

    This method is simple to code and automatically adjusts for changing volatility.

  3. Hi Wayne,

    Thanks for responding. I too have come up with a simliar approach. Using a set # of prior "period" averages to determine a constant value instead of simply saying "anything greater than 5 is a long body". I like ranking it in a top percentile.. great insight.

    Either way, we both have suggested using an absolute value for the number of prior periods (you say trading days but i'm a more short-term trader so we'll compromise on saying periods, but in your case, 1 period = 1 day)... is there a way around this.. to create a dynamic # of periods based on volume averages, perhaps?
  4. kww


    I haven't done that, but sure, you could vary the period based on any factor you choose. Before I do something like that, though, I like to have a rationale for why it might work. I like to think that helps guard against curve fitting.

    What do you see as the possible link between volume and lookback period? (And by the way, percentile ranking is also a good way to define "high" and "low" volume).