Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1288

 
YanSay:

I'm trying to do this with ShellExecuteW() as follows:

check it out here:

https://www.mql5.com/ru/forum/160683/page1243#comment_18095301

should the runtime programme and file be specified separately?
 
leonerd:


And this situation is due to what? The same bar index. And it only seems to happen on the first run on a symbol. Either deeper into the story. I thought above in the code was just checking for the presence of bars...

The same values mean a vertical line or point.
The code was written as an example for demonstration without pretending to be a clean version .
 
Aleksei Stepanenko:

have a look here:

https://www.mql5.com/ru/forum/160683/page1243#comment_18095301

Maybe you should specify the program to be executed and the file separately?

Great, it worked, thank you!

Now all that's left to do is to build an execution check into the code to make sure the code doesn't continue until the script executes, any advice on how to implement this?

I'm sure there is a more reliable and proper way than Sleep().

#import "shell32.dll"
int ShellExecuteW(int hWnd, string lpVerb, string lpFile, string lpParameters, string lpDirectory, int nCmdShow);
#import
#define  SW_SHOW 5
#define  SW_SHOWNORMAL 1

void OnStart()
{
   ShellExecuteW(NULL,"Open","python.exe","C:\\Users\\yansa\\Desktop\\test_script.py",NULL,SW_SHOW); 
   Sleep(10000);
   //Code continues
}
 

Can you tell me how to make the EA return to OnInit() in an if condition?

 if(buy_lots>0||sell_lots>0)
  { Go to OnInit();}
 
MakarFX:

How can you make the EA return to OnInit() in an if condition?

Wrap the code you use in OnInit() in a separate function and call this function from OnInit() and if necessary from your if()

 
YanSay:

Great, it worked, thank you!

Now all that's left to do is to build an execution check into the code to make sure the code doesn't continue until the script executes, any advice on how to implement this?

I'm sure there's a more reliable and proper way than Sleep().

I've done some experiments too - I opened camera, but cannot close it - until I kill the process.

//+------------------------------------------------------------------+
//|                                                            1.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#import "shell32.dll"
int ShellExecuteW(int hWnd, string lpVerb, string lpFile, string lpParameters, string lpDirectory, int nCmdShow);
#import
#define  SW_SHOW 5
#define  SW_SHOWNORMAL 1
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   ShellExecuteW(NULL,"Open","C:\\Program Files (x86)\\Lenovo\\YouCam\\YouCam.exe","",NULL,SW_SHOW); 
  }
//+------------------------------------------------------------------+
 
Igor Makanu:

Wrap the code you use in OnInit() in a separate function and call this function from OnInit() and, if necessary, from your if()

I see what you mean. Isn't there anything simpler, like ExpertReload..Restart?
 
MakarFX:
I see what you mean. Is there anything easier, like ExpertReload..Restart?

no

In MQL the event-based model, which implies that OnInit, OnTick ... is only made by the terminal

if you want a complex solution ... Well, switch the TF from the EA - callOnInit, I doubt you were looking for that ;)

 
MakarFX:
I see what you mean. Is there nothing simpler, like ExpertReload..Restart?

returnee from ontic

 
Igor Makanu:

no

In MQL the event-based model, which implies that OnInit, OnTick ... is only made by the terminal

if you want a complex solution ... Well, switch the TF from the EA - callOnInit, I doubt you were looking for that ;)

Thank you, I see.