//
http://www.amibroker.org/userkb/2008/08/30/popup-window-preventing-pile-ups/
//
http://www.amibroker.com/members/feedback/view_bug.php?bug_id=1528
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
function secleft()
{
currtime = Now ( 4 );
hr = int ( currtime / 10000 );
mnt = int ( ( currtime - hr * 10000 ) / 100 );
sec = currtime - hr * 10000 - mnt * 100;
totalsec = hr * 60 ^ 2 + mnt * 60 + sec;
left = Interval() - totalsec % Interval();
return left;
}
function PopupWindowEx( popupID, bodytext, captiontext, timeout, left, top )
{
displayText = bodytext + "_" + captiontext;
if ( ( StaticVarGetText( "prevPopup:" + popupID ) != displayText) OR
( StaticVarGet( "prevPopupTime" + popupID ) < GetSecondNum() ) )
{
StaticVarSetText( "prevPopup:" + popupID, displayText);
StaticVarSet( "prevPopupTime" + popupID, GetSecondNum() + timeout );
PopupWindow( bodytext, Captiontext + popupID, timeout, Left, top );
}
}
/////////////////////////////////////////////////////////////////////////
// one time popup example by trash ....
//
http://www.traderji.com/newreply.php?do=postreply&t=78419
/////////////////////////////////////////////////////////////////////////
Buy = type condison ;
Sell = type condison ;
if( Status( "action" ) == actionIndicator )
{
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
alertstr = Name() + "_Last Bartime:" + DateTimeToStr( LastValue( DateTime() ) );
buyid = "ID:1";
sellid = "ID:2";
duration = secleft(); // one popup ocurrence AFTER confirmed signal
if ( LastValue( Ref( Buy, -1 ) ) )
PopupWindowEx( buyid, "Buy " + alertstr, "Buy Alert", duration, -1, -1 );
if ( LastValue( Ref( Sell, -1 ) ) )
PopupWindowEx( sellid, "Sell " + alertstr, "Sell Alert", duration, 0, 0 );
// Title = "Intrabar " + StaticVarGetText( "prevPopup:" + buyid ) +
// "\nIntrabar " + StaticVarGetText( "prevPopup:" + sellid ) +
// "\nBartime left: "+ duration;
// Plot( Buy, "True Buy Sig", colorGreen,C, 0, 1, 0, 0, width = -80 );
// Plot( Sell, "True Sell Sig", colorRed, C, 0, 1, 0, 0, width );
}
/*
Buy = Cross(MACD(),Signal());
Sell = Cross(Signal(),MACD());
Plot(MACD(),"MACD",colorRed,styleThick);
Plot(Signal(),"SIGNAL",colorBlue,styleThick);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Filter = Buy OR Sell;
//alert
AlertIf( Buy , "SOUND C:\\Windows\\Media\\chimes.wav", "jim-Audio Buy Alert", 2 );//correct
AlertIf( Sell , "SOUND C:\\Windows\\Media\\Ding.wav", "Jim-Audio SELL Alert=" , 1+2 );//correct
//AlertIf( Buy, "Buy", "BUY@ +C=", 1, 1+2 );
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 1 );//2
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
function PopupWindowEx( popupID, bodytext, captiontext, timeout, left, top )
{
displayText = bodytext + captiontext;
if ( ( StaticVarGetText( "prevPopup" + popupID ) != displayText) OR ( StaticVarGet( "prevPopupTime" + popupID ) < GetSecondNum() ) )
{
StaticVarSetText( "prevPopup" + popupID, displayText);
StaticVarSet( "prevPopupTime" + popupID, GetSecondNum() + timeout );
PopupWindow( bodytext, Captiontext + popupID, timeout, Left, top );
}
}
PopupWindowEx( "ID:1", "BUY", "BUY alert ", 5, -1, -1 );
PopupWindowEx( "ID:2", "SELL", "SELL alert ", 5, 0, 0 );