I hardheartedly appreciate @Tomasz for taking out your valuable time for this!

May I please draw you attention to a piece of code written by Edward, kindly:

N.B.

- Mouse Left Button Down - to draw the spiral, then,
- Mouse Middle Button - to lock the pattern.
- And to free for a new drawing - GUI Button.

```
// AFL by E.M.Pottasch, 5/2018
// Translated from code posted in: Fibonacci Applications and Strategies for Traders (Robert Fischer, 1993)
// https://forum.amibroker.com/t/eadem-mutata-resurgo-logarithmic-spiral-in-amibroker-fibonacci-elliott-fischer/5764/10
dir = ParamToggle( "Direction", "ClockWise|Counter ClockWise", 0 );
stepCount = Param( "stepCount", 512, 1, 1024, 1 );
incr = Param( "Increment (Radians)", 0.1, 0.01, 1, 0.01 );
pixmode = ParamToggle( "Chart Mode", "Real Coordinates Mode|Pixel Mode", 1 );
SetBarsRequired( sbrAll );
RequestTimedRefresh( 1 );
GfxSetZOrder( 5 );
if( dir == 0 )
{
DIR = 1;
}
else
{
DIR = -1;
}
function ConvertBarToPixelX( bar )
{
lvb = Status( "lastvisiblebar" );
fvb = Status( "firstvisiblebar" );
pxchartleft = Status( "pxchartleft" );
pxchartwidth = Status( "pxchartwidth" );
if( ( lvb - fvb ) != 0 )
rr = pxchartleft + ( ( bar - fvb ) / ( lvb - fvb ) ) * pxchartwidth;
else
rr = 0;
return rr;
}
function ConvertValueToPixelY( Value )
{
Miny = Status( "axisminy" );
Maxy = Status( "axismaxy" );
pxchartbottom = Status( "pxchartbottom" );
pxchartheight = Status( "pxchartheight" );
if( ( Maxy - Miny ) != 0 )
rr = pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight / ( Maxy - Miny ) );
else
rr = 0;
return rr;
}
GuiSetFont( "Lucida Console", 10 );
GuiButton( "Free Spiral", 1, 10, 50, 120, 30, 7 );
GuiSetColors( 1, 1, 2, colorRed, colorBlack, colorRed, colorWhite, colorBlue, colorYellow, colorRed, colorBlack, colorYellow );
id = GuiGetEvent( 0, 0 );
event = GuiGetEvent( 0, 1 );
if( id == 1 && event == 1 )
{
Say( "Free Spiral Pattern" );
StaticVarSet( "LockSpiral", 0 );
StaticVarSet( "x1", 0 );
StaticVarSet( "y1", 0 );
StaticVarSet( "x2", 0 );
StaticVarSet( "y2", 0 );
}
bi = BarIndex();
x1 = y1 = x2 = y2 = 0;
PI = 3.141593;
PHI = ( sqrt( 5 ) + 1 ) / 2; // Golden ratio
CON = ( 1 / ( 2 * PI ) ) * Log( phi );
b = GetCursorMouseButtons();
x = GetCursorXPosition( 0 );
y = GetCursorYPosition( 0 );
if( Nz( StaticVarGet( "LockSpiral" ) ) == 0 )
{
if( b & 8 )
{
if( b & 1 )
{
RequestMouseMoveRefresh();
x = LastValue( ValueWhen( x == DateTime(), bi ) );
StaticVarSet( "x1", x );
StaticVarSet( "y1", y );
}
if( b & 4 ) // middle mouse button
{
StaticVarSet( "LockSpiral", 1 );
Say( "Lock Spiral Pattern" );
}
}
else
{
if( b == 1 )
{
RequestMouseMoveRefresh();
x = LastValue( ValueWhen( x == DateTime(), bi ) );
StaticVarSet( "x2", x );
StaticVarSet( "y2", y );
}
}
}
SetChartOptions( 0, chartShowDates );
SetChartBkColor( ColorRGB( 0, 0, 0 ) );
Plot( C, "", colorWhite, styleCandle, Null, Null, 0, 0, 1 );
P1X = StaticVarGet( "x1" );
P1Y = StaticVarGet( "y1" );
P2X = StaticVarGet( "x2" );
P2Y = StaticVarGet( "y2" );
if( pixmode )
{
P1X = ConvertBarToPixelX( P1X );
P1Y = ConvertValueToPixelY( P1Y );
P2X = ConvertBarToPixelX( P2X );
P2Y = ConvertValueToPixelY( P2Y );
}
DX = P2X - P1X;
DY = P2Y - P1Y;
R0 = sqrt( DX ^ 2 + DY ^ 2 );
A0 = atan2( DY, DX );
if( !pixmode )
{
GfxSetCoordsMode( 1 );
}
GfxSelectFont( "Tahoma", 10, 700 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorYellow );
GfxTextOut( "Center", P1X, P1Y );
GfxTextOut( "Start", P2X, P2Y );
GfxSelectPen( colorGreen, 2 );
GfxMoveTo( P1X, P1Y );
GfxLineTo( P2X, P2Y );
GfxSelectPen( colorDarkBlue, 2 );
A = 0;
// start point B
TP1X = P2X;
TP1Y = P2Y;
GfxMoveTo( TP1X, TP1Y );
if( R0 > 0 || !IsEmpty( R0 ) )
{
for( step = 0; step < stepCount; step++ )
{
A = A + incr;
R = R0 * exp( CON * A );
TA = A * DIR + A0;
TP2X = cos( TA ) * R + P1X;
TP2Y = sin( TA ) * R + P1Y;
GfxLineTo( TP2X, TP2Y );
TP1X = TP2X;
TP1Y = TP2Y;
}
}
```

As you would notice upon toggling the Param - Chart Mode - quite understandably, in pixel mode the arc of the spiral does not get fixed to the bar-price upon Zoom in/out which gets resolved upon calling the good `GfxSetCoordsMode( 1 )`

function but this time the continuous shape of the Spiral gets affected. That is a bit disheartening!

What I am struggling with is about a method by which we could fix the spiral's pattern correctly to the bars/price by appropriate scaling or offseting it with the bars and price in the pixel mode.

For instance, offsetting the pixelated GFX attributes with the Plot() as in the below code:

```
Plot( C, "Price", colorDefault, styleLine );
GfxSetOverlayMode( 1 );
GfxSetCoordsMode( 1 ); // bar/price mode (instead of pixel)
GfxSelectSolidBrush( colorRed );
GfxSelectPen( colorRed );
boxheight = 0.01 * ( HighestVisibleValue( C ) - LowestVisibleValue( C ) );
bi = BarIndex();
start = FirstVisibleValue( bi );
end = LastVisibleValue( bi );
offset = Param( "offset", 1, 0.01, 1, 0.01 );
for ( i = start; i <= end; i++ )
{
j = i * offset;
Cl = Close[ i ];
Op = Open[ i ];
Color = IIf( Cl > Op, colorGreen, colorRed );
GfxSelectPen( Color );
GfxSelectSolidBrush( Color );
bodyup = Max( Op, Cl );
bodydn = Min( Op, Cl );
GfxEllipse( j - 0.4, bodyup, j + 0.4, bodydn );
GfxMoveTo( j, H[ i ] );
GfxLineTo( j, bodyup );
GfxMoveTo( j, bodydn );
GfxLineTo( j, L[ i ] );
}
```

Your guidance will immensely help!

Extremely thankful for transforming your creative imagination into reality.