PureBytes Links
Trading Reference Links
|
Chris,
>Anyone have any circle drawing code they'd be willing to share?
You can't draw circles unless you know that the x and y axes have
the same scale. Otherwise you can only draw ellipses.
The best way to draw an ellipse is to use polar coordinates and draw
a line segment at every angle increment. However, in TradeStation
this isn't practical because the X-axis values aren't continuous
(for example you can't plot a point mid-way between two bars).
Therefore one needs to do it in cartesian coordinates, using the X
values that we have available. I'll explain the method in general
terms and you can figure out the code.
If the width of the ellipse is 2*a and the height is 2*b, and the
center the ellipse is at (x0, y0), then the equation for an
ellipse is
(x-x0)^2 / a^2 + (y-y0)^2 / b^2 = 1
Solving for y, we get
y = SquareRoot(b^2 * (1 - (x-x0)^2 / a^2)) + y0
Once you have this formula, you can draw an elliptical arc above the
(x0,y0) origin, and an elliptical arc below the origin, to make the
whole ellipse. You'd have to use trendlines to draw the arcs.
--
,|___ Alex Matulich -- alex@xxxxxxxxxxxxxx
// +__> Director of Research and Development
// \
// __) Unicorn Research Corporation -- http://unicorn.us.com
|