Calling another program from AFL

#1
Hi.. Does anyone know how to call another executable or any other program from within a AFL?
I need to send myself some alerts on email while I work in office. I have written a small vb.net program and I want to invoke/call this program from AFL after certain conditions are met.
 
#2
Hi.. Does anyone know how to call another executable or any other program from within a AFL?
I need to send myself some alerts on email while I work in office. I have written a small vb.net program and I want to invoke/call this program from AFL after certain conditions are met.
Use ALERTIF Function:-
ALERTIF
- trigger alerts

SYNTAX AlertIf( BOOLEAN_EXPRESSION, command, text, type = 0, flags =
1+2+4+8, lookback = 1 );
RETURNS nothing
FUNCTION Triggers alert action if BOOLEAN_EXPRESSION is true.
1. BOOLEAN_EXPRESSION is the expression that if evaluates to True
(non zero value) triggers the alert. If it evaluates to False (zero
value) no alert is triggered. Please note that only lookback most
recent bars are considered.
2. The command string defines the action taken when alert is
triggered. If it is empty the alert text is simply displayed in the
Alert output window (View->Alert Output). Other supported values of
command string are:
SOUND the-path-to-the-WAV-file
EMAIL
EXEC the-path-to-the-file-or-URL
SOUND command plays the WAV file once.
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
Body: text
EXEC command launches external application or file or URL specified
after EXEC command. are attached after file name and text is
attached at the end
3. Text defines the text that will be printed in the output window
or sent via e-mail or added as argument to the application specified
by EXEC command

4. Type defines type of the alert. Pre-defined types are 0 -
default, 1 - buy, 2 - sell, 3 - short, 4- cover. YOu may specify
higher values and they will get name "other"
5. Flags control behaviour of AlertIF function. This field is a
combination (sum) of the following values:
( 1 - display text in the output window, 2 - make a beep (via
computer speaker), 4 - dont display repeated alerts having the same
type, 8 - dont display repeated alerts having the same date/time)
By default all these options are turned ON.
6. lookback parameter controls how many recent bars are checked
EXAMPLE Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Sell;
Cover = Buy;
AlertIF( Buy, "EMAIL", "A sample alert on "+FullName(), 1 );
AlertIF( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert",
2 );
AlertIF( Short, "EXEC Calc.exe", "Launching external application", 3
);

AlertIF( Cover, "", "Simple text alert", 4 );
Note EXEC command uses ShellExecute function and allows not only EXE
files but URLs too.

Hope this Helps. The abovementioned is from User Guide

Sanjeev Bhatia
 
#4
Inorder to get a email when you generate a signal can be done using the following.

1. You need Amibroker 5.30 and above for this facility

Download and run SSL add-on from http://www.amibroker.com/bin/SSLAddOn.exe

Configure (Tools->Preferences->Alerts) with SSL enabled as shown below


;





And then while writing the code make use of the following syntax


//This is just an example
Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Sell;
Cover = Buy;

AlertIF( Buy, "EMAIL", "A sample alert on "+FullName(), 1 );



This would send a mail to the email id set in the preferences.

Hope this helps.
 
Last edited:
#5
Inorder to get a email when you generate a signal can be done using the following.

1. You need Amibroker 5.30 and above for this facility

Download and run SSL add-on from http://www.amibroker.com/bin/SSLAddOn.exe

Configure (Tools->Preferences->Alerts) with SSL enabled as shown below

;





And then while writing the code make use of the following syntax


//This is just an example
Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Sell;
Cover = Buy;

AlertIF( Buy, "EMAIL", "A sample alert on "+FullName(), 1 );



This would send a mail to the email id set in the preferences.

Hope this helps.
Thank you Ashish. Actually, email was just an example. I want to call another executalbe as well.But yes, what you told is also a handy option for those who want email notifications :)
 
#6
On a different note, I found that you can use vbscript or jscript in AFL.
But it didnt work for me... I create a simple program, and just declared a variable, but AFL says that as error exists, but does not show any error message.

Can someone try this code..
Create a empty afl and just copy paste

EnableScript("vbscript");
<%
set x=10;

%>

If this works, then we can use Wscript.run object to call external programs.
 
Last edited:

bharatk8

Active Member
#7
Is any body using AlertIf,ShellExecute for launching external applications or "integration" with URL?

Pl. elaborate so that we explore enhancement of capabilities of AB.
Note EXEC command uses ShellExecute function and allows not only EXE
files but URLs too.

Hope this Helps. The abovementioned is from User Guide

Sanjeev Bhatia
 
#8
Is any body using AlertIf,ShellExecute for launching external applications or "integration" with URL?

Pl. elaborate so that we explore enhancement of capabilities of AB.
Hi,

I use AlertIf() for triggering alerts but for executing external applications, I use ShellExecute() - as explained here : http://tradinganalysis.co.in/AmiBroker_Help/shellexecute.html

Can help further if you specify the specific purpose. Please PM as I don't get time to check forums often.

Hope this helps.

CA
 

msa5678

Well-Known Member
#9
Hi,

I use AlertIf() for triggering alerts but for executing external applications, I use ShellExecute() - as explained here : http://tradinganalysis.co.in/AmiBroker_Help/shellexecute.html

Can help further if you specify the specific purpose. Please PM as I don't get time to check forums often.

Hope this helps.

CA
Dear Friends,

I will outline a more simple procedure to automatically send snapshot of Ami through E-mail.

Step 1 = Download "Hotkey".
Step 2 = Write Script for Hotkey like this...

^k::
Loop, 200
{
MouseClick, left, 268, 112 ; First top tab
sleep, 20000
send !fe
sleep, 3000
send [email protected]
sleep, 3000
send {tab}
sleep, 3000
send "Subject of mail here"
sleep, 3000
send !s
Sleep, 110000
}

Step 3: Pressing "Ctrl k" , With the Ami open , Launches the script and will send the chart to your e-mail every 3 mins, for 200 loops. Both the loops and the time between each mail can be changed.

 
Last edited:

bharatk8

Active Member
#10
I am not able to PM.Pl. enable PM.

Hi

I saw a code for making phone call from SKYPE.This code prompted me to explore other possibilities too.

For what purpose do you use ShellExecutive?

Regards

bharat
Hi,

I use AlertIf() for triggering alerts but for executing external applications, I use ShellExecute() - as explained here : http://tradinganalysis.co.in/AmiBroker_Help/shellexecute.html

Can help further if you specify the specific purpose. Please PM as I don't get time to check forums often.

Hope this helps.

CA
 

Similar threads