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

Re: Can anyone help me fix my circle math?



PureBytes Links

Trading Reference Links

You guys are making this harder than it should be. :-)


In the attached figure (Omega.08) - for a circle we know:

   R^2 = a^2 + y^2

so: y = SQRT(R^2 -a^2)

Since: a + b = R 

then:  a = b - R

so: y = SQRT(R^2 - a^2) 
      = SQRT(R^2 - (b - R)^2)
      = SQRT(R^2 - b^2 + 2*b*R - R^2)
      = SQRT(    - b^2 + 2*b*R      )
      = SQRT( 2*b*R - b^2)

      = SQRT( b * (2*R - b))


This gives us the height as a function of the horizontal distance "b"

To translate this into TradeStation code:

Let: b = CurrentBar - cpBar - R 

where: cpBar is the bar number of the center point.

Add a scale factor to adjust the price scale and you get the code below.

The second picture Omega.09 shows the circle. Inside it is a circle drawn with the TradeStation drawing tools. They look pretty similar to me...

Bob Fulks

-----------------------------------------------------

Input: R(50), cpBar(250), cpPrice(1200), ScaleFac(1.0);

Var: b(0), y(0);

b = CurrentBar - cpBar + R;

if b >= 0 and b <= 2 * R then begin
   y = ScaleFac * SquareRoot(b * (2 * R - b));
   Plot1(cpPrice + y, "Upper");
   Plot2(cpPrice - y, "Lower");
end;

------------------------------------------------------

Attachment: Omega.08.png
Description: PNG image

Attachment: Omega.09.png
Description: PNG image