Popup alert in Amibroker-problem of multi popups

rvlv

Active Member
#1
Hi friends
here is a code for pop up alert.
problem is many popups keep coming.

can a expert suggest a way out please!
//==================================================
_SECTION_BEGIN("POPUP");//pop up alert




Buy=MACD()>SIGNAL();
SELL = MACD()<SIGNAL();
PlotShapes( IIf( Buy, shapeDownArrow + shapePositionAbove, shapeNone ), colorGreen );
PopupWindow("Buy : " + FullName(),"Alert", 5, 640*mtRandom(), 480*mtRandom());



PlotShapes( IIf( Sell, shapeUpArrow + shapePositionAbove, shapeNone ), colorRed );
PopupWindow("Sell : " + FullName(),"Alert", 5, 640*mtRandom(), 480*mtRandom());

_SECTION_END();

========================
Once this code lines are added to an afl,after removing buy,sell code lines, it will give popups.

but there are multiple popups allover the chart.
I am looking for just a single buy or sell alert from one chart where the afl has the above code lines.

thanks in advance
regards
 

sr114

Well-Known Member
#2
Hi friends
here is a code for pop up alert.
problem is many popups keep coming.

can a expert suggest a way out please!
//==================================================
_SECTION_BEGIN("POPUP");//pop up alert




Buy=MACD()>SIGNAL();
SELL = MACD()<SIGNAL();

buy = exrem ...... //use exrem code here
sell = exrem .....

PlotShapes( IIf( Buy, shapeDownArrow + shapePositionAbove, shapeNone ), colorGreen );
PopupWindow("Buy : " + FullName(),"Alert", 5, 640*mtRandom(), 480*mtRandom());



PlotShapes( IIf( Sell, shapeUpArrow + shapePositionAbove, shapeNone ), colorRed );
PopupWindow("Sell : " + FullName(),"Alert", 5, 640*mtRandom(), 480*mtRandom());

_SECTION_END();

========================
Once this code lines are added to an afl,after removing buy,sell code lines, it will give popups.

but there are multiple popups allover the chart.
I am looking for just a single buy or sell alert from one chart where the afl has the above code lines.

thanks in advance
regards
use exrem to reduce excessive signals.

Buy=Exrem(Buy,Sell);
Sell=Exrem(Sell,Buy);


use this

rgds
subroto
 

rvlv

Active Member
#3
Hi subroto

THanks.
situation no change.
code gives 2 popups buy and sell in market closed condition
i will check in live market.

regards
 

rvlv

Active Member
#4
more info on popup window & control from Amibroker kb

August 30, 2008
Popup Window: Preventing pile-ups

By Dennis Brown

The popup window is a great tool in debugging and can help you to keep track of what your code is doing or it can be used to alert you to special situations in your normally running formula. A common problem is that if you call PopupWindow() from a loop or if one gets generated on every AFL pass, you can get hundreds or even thousands of pop-ups piling up on your screen. Tomasz posted a simple work-around on the AmiBroker Feedback Center that took care of the problem in some cases (Suggestion 1528):

The following is a more complete version of this solution that adds a popupID to keep track of each individual popup window and re-enable the popup after its specified timeout period, or if any of the displayed text changes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23



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", "testing", "test alert ", 5, -1, -1 );
PopupWindowEx( "ID:2", "testing", "test alert ", 5, 0, 0 );
 
#5
Hi subroto
please take a look at this.
can you fix this popupwindow problem-two windows come both buy & sell.
actually in a sell time,only sell popupwindow should appear.but buy also shows up.
the window has to be linked to time of alert buy signal or sell signal

thanks
regards
-----------------------------------------------------------------
HTML:
  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 );
 
#6
Hi subroto ,Smart trade

please take a look at this afl.
please find a way out to get only one popupwindow alert when a buy signal or sell signal comes.

one guy when asked ovr chat told me-"Right now Amibroker is not geared for this kind of alert -use MT4"
I like only Amibroker .

thanks
 

trash

Well-Known Member
#8
Hi subroto ,Smart trade

please take a look at this afl.
please find a way out to get only one popupwindow alert when a buy signal or sell signal comes.

one guy when asked ovr chat told me-"Right now Amibroker is not geared for this kind of alert -use MT4"
I like only Amibroker .

thanks
Your so called "guy" (by any chance is that guy you?) is just one giant blabbermouth.

Here is my example usage.
One popup AFTER confirmed signal.

Code:
// 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
/////////////////////////////////////////////////////////////////////////

period = 5; // number of averaging periods 
m = MA( Close, period ); 
Buy = Cross( Close, m );
Sell = Cross( m, Close );

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, styleHistogram, 0, 1, 0, 0, width = -80 );
	Plot( Sell, "True Sell Sig", colorRed, styleHistogram, 0, 1, 0, 0, width ); 
}
 

Similar threads