Hi,
I would like my code to generate alert (and sounds) when a specific price level is crossed. This price level is set by me dynamically by using mouse click + ctrl button. I have used getcursormousebuttons and getcursoryposition for this purpose. But the problem is that alert is removed after the mouse click + ctrl is done. And also I am not able to mark the price level (Y) using the plotshapes. Below is the code. any help will be appreciated.
b = GetCursorMouseButtons();
ctrlkeydown = GetAsyncKeyState(17) < 0;
// retrieve co-ordinates in date/value units
x = GetCursorXPosition(0);
y = GetCursorYPosition(0);
if( b & 8 ) // flag = 8 is set when window just received mouse click
{
// not-null means clicked in THIS (current) window
if( b & 1 AND ctrlkeydown)
{
Plotshapes( shapeSmallSquare, colorBlue, 0,y );
AlertIf( Cross(C,y), "SOUND C:\\Windows\\Media\\Alarm02.wav", "Audio alert", 1 ,2);
}
}
Plot( C, "Price", colorDefault, styleCandle );
SVAlertLine= Nz(StaticVarGet("SVAlert΄"));
b = GetCursorMouseButtons();
ctrlkeydown = GetAsyncKeyState(17) < 0;
// retrieve co-ordinates in date/value units
x = GetCursorXPosition(0);
y = GetCursorYPosition(0); //y - value gives PRICE
if( b & 8 ) // flag = 8 is set when window just received mouse click
{
// not-null means clicked in THIS (current) window
if( b & 1 AND ctrlkeydown)
{
// Store the Y value to the staticVariable and then use it later
StaticVarset("SVAlert΄",Y);
}
}
// do something if statickVar has a value > 0
if( SVAlertLine > 0 )
{
//Plotshapes( shapeSmallSquare, colorBlue, 0, SVAlertLine ); //please DONOT USE Plotshapes
Plot(SVAlertLine,"",ParamColor("Horizontal Line Color",colorBlue),1 | styleNoLabel);
AlertIf( Cross( C, SVAlertLine ), "SOUND C:\\Windows\\Media\\Alarm02.wav", "Audio alert", 1 , 2 );
}
P.S
Just remember use GFX to plot the lines instead of plotshape