Hello!

I don't know if the subject describes my issue accurately so please change if need be.

I am coming here for help... not sure I have the knowhow to understand exactly what is going on with my formula.

I have modified a formula I found on this forum (unsure where at this point) to start drawing lines when I have the Right Shift key down... and it does it perfectly.

Where I have an issue is that the drawings don't seem to load with every start... for example I draw stuff, close amibroker, restart it... they are not there. Close Amibroker again and restart and then they show back up. Could anyone give me pointers as to what I should do to understand what is going on here?

Images below because video is too big:

Image 1 shows 10 drawings...

Then I close amibroker and restart... nothing shows up... see below.

Then I close again and restart... drawings shows up again

Not sure if I am allowed to post outside links here but here goes just in case a link to the full video

Formula here:

```
_SECTION_BEGIN("Drawings");
EnableTextOutput(False);
GfxSetZOrder(0);
GfxSetCoordsMode(1);
X=GetCursorXPosition(0);
Y=GetCursorYPosition(0);
ChartID=Name()+Interval()+GetChartID();
DrCounter=StaticVarGet("DrawCount"+ChartID);
printf("\nDrCounter="+DrCounter);
GetClick=GetCursorMouseButtons();
Click8=GetClick&8;
Click9=GetClick&9;
Click4=GetClick&4;
if (GetAsyncKeyState(161)<0) {
if (Click8) {
DrCounter=Nz(StaticVarGet("DrawCount"+ChartID));
StaticVarSet("DrawX1"+ChartID+(DrCounter+1),X,1);
StaticVarSet("DrawY1"+ChartID+(DrCounter+1),Y,1);
StaticVarSet("DrawCount"+ChartID,DrCounter+1,1);
}
if (Click9) {
DrCounter=Nz(StaticVarGet("DrawCount"+ChartID));
StaticVarSet("DrawX2"+ChartID+DrCounter,X,1);
StaticVarSet("DrawY2"+ChartID+DrCounter,Y,1);
}
if (Click4) {
DrCounter=Nz(StaticVarGet("DrawCount"+ChartID));
StaticVarRemove("DrawX1"+ChartID+DrCounter);
StaticVarRemove("DrawY1"+ChartID+DrCounter);
StaticVarRemove("DrawX2"+ChartID+DrCounter);
StaticVarRemove("DrawY2"+ChartID+DrCounter);
StaticVarSet("DrawCount"+ChartID,Max(DrCounter-1,0),1);
}
RequestMouseMoveRefresh();
}
Index=BarIndex();
GfxSetBkMode(1);
GfxSetTextColor(colorRed);
GfxSelectPen(colorRed,2);
if (DrCounter>0) {
for (i=1;i<=DrCounter;i++) {
DrawX1=Lookup(Index,StaticVarGet("DrawX1"+ChartID+i));
DrawX2=Lookup(Index,StaticVarGet("DrawX2"+ChartID+i));
DrawY1=StaticVarGet("DrawY1"+ChartID+i);
DrawY2=StaticVarGet("DrawY2"+ChartID+i);
printf("\nY1-"+i+"_"+NumToStr(DrawY1,1.2,False));
printf("\nY2-"+i+"_"+NumToStr(DrawY2,1.2,False));
if (DrawX1!=0 && DrawX2!=0) {
GfxMoveTo(DrawX1,DrawY1);
GfxLineTo(DrawX2,DrawY2);
}
}
}
RequestTimedRefresh(1);
_SECTION_END();
```