the thing about scaled charts ...
Posted: Tue Feb 25, 2025 3:30 pm
is they let you see this:
The Natural Law Trading Community
http://groups.wave59.com/
Code: Select all
#
# 3PointCircle
#
# Draw a circle using 3 hot spots
# or
# Draw a circle using 2 hot spots and a radius (use 3rd hot spot to define direction of the circle)
#
# threepointcircle = true - circle defined with 3 hot spots
# = false - circle defined with 2 hot spots and a radius
#
input: threepointcircle(false),radius(150),logclear(true),displayradius(false),circlecolor(blue),circlestyle(ps_solid),circlethickness(1);
#
if (barnum == barsback)
{
if (logclear) clearlog();
bar1=hotspot_to_bar(1);
price1=hotspot_to_price(1);
cx1=bar_to_pixel(bar1);
cy1=price_to_pixel(price1);
bar2=hotspot_to_bar(2);
price2=hotspot_to_price(2);
cx2=bar_to_pixel(bar2);
cy2=price_to_pixel(price2);
bar3=hotspot_to_bar(3);
price3=hotspot_to_price(3);
cx3=bar_to_pixel(bar3);
cy3=price_to_pixel(price3);
dcx=cx2-cx1;
if (dcx!=0)
{
ma=(cy2-cy1)/(cx2-cx1);
}
else
{
return;
}
ty3=cy1+ma*(cx3-cx1);
if (ty3<cy3)
{
upcircle=false;
}
else if (ty3>cy3)
{
upcircle=true;
}
else
{
print "Coliner hot spots";
return;
}
print "upcircle= ",upcircle;
if (threepointcircle==true)
{
mb=(cy3-cy2)/(cx3-cx2);
x0=(ma*mb*(cy1-cy3)+mb*(cx1+cx2)-ma*(cx2+cx3))/(2*(mb-ma));
y0=-(x0-(cx1+cx2)/2)/ma+(cy1+cy2)/2;
radius=sqrt((cx1-x0)*(cx1-x0)+(cy1-y0)*(cy1-y0));
print "t-x0= ",x0," y0= ",y0;
}
else
{
cxh=(cx1+cx2)/2;
cyh=(cy1+cy2)/2;
aa=cxh/ma+cyh;
ay=cy1-aa;
ae=1+1/(ma*ma);
be=2*(-cx1+ay/ma);
ce=cx1*cx1+ay*ay-radius*radius;
de=sqrt(be*be-4*ae*ce);
x01=(-be+de)/(2*ae);
x02=(-be-de)/(2*ae);
y01=-(x01-(cx1+cx2)/2)/ma+(cy1+cy2)/2;
y02=-(x02-(cx1+cx2)/2)/ma+(cy1+cy2)/2;
if (upcircle==true)
{
if (y01<=y02)
{
x0=x01;
y0=y01;
}
else
{
x0=x02;
y0=y02;
}
}
else
{ # upcircle == false
if (y01<=y02)
{
x0=x02;
y0=y02;
}
else
{
x0=x01;
y0=y01;
}
}
print "f-x0= ",x0," y0= ",y0;
}
print "r= ",radius;
canvas_pencolor(circlecolor);
canvas_penwidth(circlethickness);
canvas_penstyle(circlestyle);
x1=x0-radius;
y1=y0-radius;
x2=x0+radius;
y2=y0+radius;
canvas_ellipse(x1, y1, x2, y2);
if (displayradius==true)
{
canvas_movepen(x0,y0);
#canvas_pencolor(uptrendlinecolor);
#canvas_penwidth(uptrendlinethickness);
#canvas_penstyle(uptrendlinestyle);
canvas_lineto(cx1,cy1);
}
}