# Draw circul at two MA cross

Hello i want to plot a dark yellow circul when my two moving averages 20 and 50 is cross each other
How i find X and Y coordinate at that crossing point i does not use buy shape arrow
Is there any read X and Y coordinate command at particular point

One possible solution:

``````fvbi = Status( "firstvisiblebarindex" ); lvbi = Status( "lastvisiblebarindex" );
Avg1 = MA( C, 20 ); Avg2 = MA( C, 50 );
GfxSetCoordsMode( 1 ); GfxSetOverlayMode( 1 );
GfxSelectPen( colorOrange, 2 ); GfxSelectSolidBrush( colorYellow );
AvgCross = Cross( Avg1, Avg2 ) OR Cross( Avg2, Avg1 );

for( i = fvbi; i <= lvbi; i++ ) if( i < BarCount ) if( AvgCross[i] ) GfxCircle( i, ( Avg1[i] + Avg2[i] ) / 2, 2.5 );

Plot( C, "C", colorDefault, styleCandle );
Plot( Avg1, "MA20", colorGreen, styleLine );
Plot( Avg2, "MA50", colorRed, styleLine );
`````` Maybe it's not perfect (I'm talking about accuracy), but it's simple (of course the simplest solution would be using PlotShapes). I used `GfxSetCoordsMode(1)` and for this reason calculating x,y pixel coordinates is not required A quote from: http://amibroker.com/guide/afl/gfxsetcoordsmode.html

mode = 1 - bar / price mode where X is expressed in bar index and Y is expressed in price. This new mode allows way easier overlays on top of existing charts without need to do conversion between bars/price pixels and without any extra refresh normally required in old versions when Y scale changed.

5 Likes