detection of a 2 point down trend touch line

Discussion in 'Technical Analysis' started by hanhao, Jun 18, 2007.

  1. hanhao


    detection of a 2 point down trend touch line

    Hi fellow technical traders. i am trying to code an algorithm for the detection of a 2 point down trend touch in the last 6 months or so and automatically drawing the trendline. A 2 point down trend touch line is where the stock is trending down and the trendline is drawn across 2 of it's most highest more protruding highs. perhaps a picture would be better to explain this. The link for this picture is


    is there any exsisting indicator to help me with this? if not, can anyone suggest an algorithm to get this other than drawing the trendline mannually? i am currently coding in metastocks

    many thanks! :)
  2. You have a trendline drawn there. How did you decide that that is the trendline? For any chart with more than two bars/candles there is more than one trendline that can be drawn. With more than two bars/candles, you are going to have to choose one of many potential trend lines. How do you do that?

    You choose the one that is only touched by two bars/candles? What if there is a trendline that is touched by more than two bars/candles? A better trendline on your chart might be one that touches in at least four places.

    I am trying to get clear on the problem.
  3. nkhoi

    nkhoi Moderator

    try zig zag indicator
  4. hanhao


    thnx for your advise
    what i want to draw is a 2 point trend line. i know it's bad using simply 2 points, but the system i am writing requires exactly 2 points in the manner shown on the picture.
  5. What about a short ema (4 or 8), then linearize that curve (least squares? (it's been awhile)). I don't know whether that would give you more than two points.
  6. I have an indicator for MetaTrader that does exactly what you describe. Here's a screenshot of it in action. It's a huge timesaver for me.

    I can post it here if you'd like. The code is half hex, so porting it to any other charting program would be rather cumbersome unfortunately. Shame b/c I'd love to have it within QuoteTracker.
    • cad.gif
      File size:
      15.5 KB
  7. nkhoi

    nkhoi Moderator

    search on 'auto regression channel', there are some softwares offer that.
  8. hanhao


    hey that's cool!
    do you have the source for it?
    post whatever u have and i will try to translate it to metastocks
  9. Here you go.

    MetaTrader (and fx feeds) are both free, so you can try it out in the program as well (just rename the extention from .txt to .mq4). It should be a standard indicator in other packages, it's really that useful.
  10. Charly


    What is it all about - this 2p trendline??

    Would you let me (us) know more about
    it once it's ready (and h.b. tested?)

    #10     Jun 19, 2007