I used below code to trigger email but it is not generating.
AlertIF( Buy, "EMAIL", "A sample alert on "+FullName(), 1);
When I test emails are triggering, I tried different combinations by giving different value to lookback such as 0, 1 but still mails are not triggering.
Any help is appreciated.
Thanks
Shiva
to encircle your problem you should work step by step :
Test your email communication first by for example ParamTrigger
SECTION_BEGIN( "Test mailing" );
trigger = ParamTrigger( "SendEmail", "*** SEND ***" );
if( trigger )
{
SendEmail( "This is subject", "Hello world\n\nHere we are sending the body of the email\n\nBest wishes" );
}
_SECTION_END();
I use Exploration for testing AlertIf, not Scan, please note Analysis settings for sample code (!)
_SECTION_BEGIN( "Exploration : AlertIf EMAIL" );
/*
!!!
Buy condition for testing: last/current bar C < O
Apply to: [*Current]
Range : [1 recent bar(s)]
!!!
*/
// Please study the documentation :
/// @link https://www.amibroker.com/guide/afl/alertif.html
// EMAIL command sends the e-mail to the account defined in the settings (Tools->Preferences->E-mail). The format of the e-mail is as follows: Subject: Alert type_name (type) Ticker on Date/Time
/// @link https://www.amibroker.com/guide/h_alerts.html
Buy = C < O; // condition
xnow = Now(2); // current timestamp to check in Email Msg
/// @link https://www.amibroker.com/guide/afl/alertif.html
AlertIf( Buy, "EMAIL", "Buy - " + xnow + " - " + FullName(), 1, 1+2 );
Filter = Buy;
AddTextColumn( Now(2), "Now", 1, colorDefault, colorDefault, 200 );
AddColumn( O, "Open", 1, colorDefault, colorDefault, 200 );
AddColumn( C, "Close", 1, colorDefault, colorDefault, 200 );
_SECTION_END();