Email alert from Amibroker........ Can anybody rectify this AFL

rammmeo

Active Member
#1
PHP:
Buycounter=0;
Sellcounter=0;
_SECTION_BEGIN("RMO");

SwingTrd1 = 100 * (Close - ((MA(C,2)+
MA(MA(C,2),2)+
MA(MA(MA(C,2),2),2) +
MA(MA(MA(MA(C,2),2),2),2) +
MA(MA(MA(MA(MA(C,2),2),2),2),2) +
MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2) +
MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2),2)+
MA(MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2),2),2)+
MA(MA(MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2),2), 2),2)+
MA(MA(MA(MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2), 2),2),2),2))/10))/(HHV(C,10)-LLV(C,10));
SwingTrd2=EMA(SwingTrd1,30);
SwingTrd3=EMA(SwingTrd2,30);
RMO= EMA(SwingTrd1,81);
Buy=Cross(SwingTrd2,SwingTrd3);
Sell=Cross(SwingTrd3,SwingTrd2);
Bull_Trend=EMA(SwingTrd1,81)>0;
Bear_Trend=EMA(SwingTrd1,81)<0;
Ribbon_kol=IIf(Bull_Trend,colorGreen, IIf(Bear_Trend,colorRed, colorBlack));
Plot(4, "ribbon", Ribbon_kol, styleOwnScale|styleArea|styleNoLabel, -0.5,100);
Impulse_UP= EMA(SwingTrd1,30) > 0;
Impulse_Down= EMA(SwingTrd1,81) < 0;
bar_kol=IIf(impulse_UP, colorBlue, IIf(impulse_Down, colorRed,IIf(Bull_Trend, colorRed, colorBlue)));
//Plot(Close,"Close",bar_kol,styleBar | styleThick );
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ),0, IIf( Buy, Low, High ) );
AlertIf( Buy, "SOUND F:\\BANSURI.wav", "Audio alert", 1);
AlertIf( Sell, "SOUND F:\\BANSURI.wav", "Audio alert", 2 );
IIf(Buy,Buycounter++,0);
IIf(Buycounter==1,AlertIf(Buy, "EXEC C:\\Program Files\\AmiBroker\\EMailerSSL.exe","buy mailllll"+Buycounter, 5,0),0);
IIf(Sell,Sellcounter++,0);
IIf(Sellcounter==1,AlertIf(Sell, "EXEC C:\\Program Files\\AmiBroker\\EMailerSSL.exe","sell mailllll"+Sellcounter, 5,0),0);


_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Title = EncodeColor(colorBlack)+WriteIf (Buy,"buycounter="+buycounter,"")+WriteIf (Sell,"sellcounter="+Sellcounter ,"");

_SECTION_END();
i hv written this code
but the prob is it sends the email
but it sends it too many times
i think with every tick it sends it
can anybody rectify this afl so tht it send the email only the first time the signal is generated
 

johnnypareek

Well-Known Member
#2
HMM Please try below given code.

HTML:
Buycounter=0;
Sellcounter=0;
_SECTION_BEGIN("RMO");

SwingTrd1 = 100 * (Close - ((MA(C,2)+
MA(MA(C,2),2)+
MA(MA(MA(C,2),2),2) +
MA(MA(MA(MA(C,2),2),2),2) +
MA(MA(MA(MA(MA(C,2),2),2),2),2) +
MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2) +
MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2),2)+
MA(MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2),2),2)+
MA(MA(MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2),2), 2),2)+
MA(MA(MA(MA(MA(MA(MA(MA(MA(MA(C,2),2),2),2),2),2), 2),2),2),2))/10))/(HHV(C,10)-LLV(C,10));
SwingTrd2=EMA(SwingTrd1,30);
SwingTrd3=EMA(SwingTrd2,30);
RMO= EMA(SwingTrd1,81);
Buy=Cross(SwingTrd2,SwingTrd3);
Sell=Cross(SwingTrd3,SwingTrd2);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Bull_Trend=EMA(SwingTrd1,81)>0;
Bear_Trend=EMA(SwingTrd1,81)<0;
Ribbon_kol=IIf(Bull_Trend,colorGreen, IIf(Bear_Trend,colorRed, colorBlack));
Plot(4, "ribbon", Ribbon_kol, styleOwnScale|styleArea|styleNoLabel, -0.5,100);
Impulse_UP= EMA(SwingTrd1,30) > 0;
Impulse_Down= EMA(SwingTrd1,81) < 0;
bar_kol=IIf(impulse_UP, colorBlue, IIf(impulse_Down, colorRed,IIf(Bull_Trend, colorRed, colorBlue)));
//Plot(Close,"Close",bar_kol,styleBar | styleThick );
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ),0, IIf( Buy, Low, High ) );
AlertIf( Buy, "SOUND F:\\BANSURI.wav", "Audio alert", 1);
AlertIf( Sell, "SOUND F:\\BANSURI.wav", "Audio alert", 2 );
IIf(Buy,Buycounter++,0);
IIf(Buycounter==1,AlertIf(Buy, "EXEC C:\\Program Files\\AmiBroker\\EMailerSSL.exe","buy mailllll"+Buycounter, 5,0),0);
IIf(Sell,Sellcounter++,0);
IIf(Sellcounter==1,AlertIf(Sell, "EXEC C:\\Program Files\\AmiBroker\\EMailerSSL.exe","sell mailllll"+Sellcounter, 5,0),0);


_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Title = EncodeColor(colorBlack)+WriteIf (Buy,"buycounter="+buycounter,"")+WriteIf (Sell,"sellcounter="+Sellcounter ,"");

_SECTION_END();
 

Similar threads