May 23, 2018, 7:56pm
My aim is to pass arguments to a python script just like we do in cmd by running the following command
python test_print.py arg1 arg2 arg3
I have added a line
ShellExecute( "python", "", "D:/Crypto/test_print.py");
It opens a python shell as follows
my test_print.py is as follows (not passing the args for now as the script is not getting executed ),
I would appreciate any help.
@ninad I may be wrong, but I think you are making a mistake in using
ShellExecute(). Look at this example of passing arguments to external file. Pay attention to the syntax:
@Milosz, re JScript, here is an example to test how to pass arguments.
(For the other users: skip all of this if you are not already comfortable with scripting).
(This code, does not do anything useful, It only prints some values using the WScript.Echo function; in Windows, this will open a small popup window with a message. Parsing the parameters and using them in additional code is to be done as needed).
Copy this JScript code in a file that you will save in the AmiBroker's scri…
A proper syntax should look like this:
ShellExecute( "filepath", "arguments", "parameters", showcmd = 1 )
May 25, 2018, 3:30pm
ShellExecute( "python" , D:/Crypto/test_print.py arg1 arg2 arg3, D:/Crypto/ );
This one works:
Had looked for a solution myself.
the "0" at the end prevents the cmd prompt from popping up.
when double-clicking on your file, windows needs to know the extension, i.e double-click executes it.
ShellExecute won't wait for your python script to finish, that may or may not be ok
try running the ShellExecute on 1 symbol + 1 bar. Otherwise you execute it many, many times
June 3, 2018, 3:43pm
All these solutions work !
This is exactly what I was looking for.
Thanks @Milosz @Dionysos @aron @jamesfisher .
June 3, 2018, 3:49pm
I did not understand exactly what did you mean by this.
I want to call this script every time I get a buy/sell signal only. I'll see how it can be done.
if you run the ShellExecute in your .afl for say backtesting, and in your database are 100 symbols, that means you execute the ShellExecute 100 times.
(provided there are not conditional "ShellExecutes")
Of course it depends on what you are trying to achieve... yet worth mentioning.