Issue with Alertif in scan

Hi All,

I wrote code to generate buy signal and it is working fine when Scan is used. Below is the output:

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

Hello Shiva,

to encircle your problem you should work step by step :

  1. 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();
  1. 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();

Best regards,
Peter