[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: back to the well again... parallel trend lines



PureBytes Links

Trading Reference Links

> please note that i don't want to connect two known points.  i want
> to draw a parallel line through a known trend line or pair of
> points. 

If you know two points, it should be pretty easy.  If your points are 
X1,Y1 and X2,Y2, then why not draw a line from X1+Z,Y1 to X2+Z,Y2?

That draws the trendline Z units vertically above the existing line.  
If you want the parallel line to be a specific distance away from the 
trendline, say H (for Hypotenuse :-), then you just need to do a 
little trig.  

The angle of the trendline is 
  theta = arctangent((Y2-Y1)/(X2-X1)).  

Theta is also the angle between a vertical line and a line 
perpendicular to your trendline.  So

  Z = H * cosine(theta)

This is off the top of my head but I think it's right...

(View this in a fixed-pitch font like Courier:)

                               . X2+Z,Y2
                            .
                         .
                      .
                   .
                .
             .  |              . X2,Y2
          . \   |           .
       .     \  | Z      .
X1+Z,Y1     H \ |     .
               \|  .
                .
             .
          .     theta
X1,Y1  .   ----------------

Gary