Hi Fellas,
I was trying to simulate manual trading by creating a BUY and SELL button to plot BUY/SELL arrows.
I started with this code below to return 1 when I click BUY and 2 when I Click Sell.
idBUY = 1;
idSELL = 2;
function CreateGUI()
{
GuiButton( "Buy", idBUY, 10, 60, 100, 30, notifyClicked );
GuiButton( "Sell", idSELL, 110, 60, 100, 30, notifyClicked );
}
function HandleEvents()
{
event = 0;
for ( n = 0; id = GuiGetEvent( n, 0 ); n++ ) // get the id of the event
{
code = GuiGetEvent( n, 1 );
switch ( id )
{
case idBUY:
event = 1;
break;
case idSELL:
event = 2;
break;
default:
break;
}
}
return event;
}
CreateGUI();
event = HandleEvents();
printf("event = %s\n", NumToStr(event));
Plot( Close, "Close", colorDefault, styleCandle );
I does return 1 or 2 but eventually returns back to 0. Any explanation why this is the case? I just cant seem to figure out how to keep the return values.
TIA.