[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 458

 
ilunga:
square brackets alone
Thank you... Although it would be better (for us dummies), of course, if such things were indicated in words in the Documentation. Because who knows: it's a strict description (like in mathematics), which retains its meaning in all formulas and all places where it (the description) applies OR it is a schematic description, which aims to show that a given parameter is just an array, and not a variable or constant, or God knows what else
 
Dear Experts, Please help.
I can't overcome the problem of automatic saving of template.
It does not insert file name in save window.
Here is the code.
// Функция выгрузки файл шаблона с текущего графика
     string slash=StringSubstr("\a",0,1);
     string path="experts\files";
     if(IsTesting()) path="tester\files";
     SaveTemplate(StringConcatenate(TerminalPath(),slash,path,slash,Symbol(),"-",TimeCurrent(),".tpl")); //загрузка шаблона с именем 
 
void SaveTemplate(string lpTemplateName)
{
    int hParent, hDlg, hEdit,hButtonSave ;
    hParent = GetAncestor(WindowHandle(Symbol(),Period()),2);
    PostMessageA(hParent,WM_COMMAND,33220,0); //вызываем окно сохранения шаблона
    Sleep(100);
    hDlg = GetLastActivePopup(hParent);//основное окно
    hEdit = GetDlgItem(hDlg,0x3E9);//поле имени файла
    SetWindowTextA(hEdit,lpTemplateName); //вводим имя шаблона
    // 0x45A
    hButtonSave = GetDlgItem(hDlg,1);             //определяем дескриптор кнопки "Сохранить"
    Print(lpTemplateName," ",hEdit," ",hDlg," ",hParent," ", hButtonSave);
    PostMessageA(hDlg,WM_COMMAND,1,hButtonSave);  //нажимаем на кнопку

}
Thanks in advance.
 
vasili:
Dear experts, please help.
I can`t cope with a problem of automatic saving of the template.
It does not insert a file name in the save window.
Here is the code.

Library with out-of-the-box MT4 control functions.

//===========================================================================================
// 4.4. Functions for setting the chart pattern.
//===========================================================================================
// 4.4.1 The function sets the specified template on the specified chart by its name in the list of templates.
void ServiceSetTemplateByName(int hwndChart, // System descriptor of the chart's window, where the template is loaded.
string sNameTemplate); // Template name in the list of templates.
//===========================================================================================
// 4.4.2 The function sets the specified template on the specified chart by its number in the list of templates. If successful, the function returns TRUE, otherwise returns FALSE.
bool ServiceSetTemplateByNumber(int hwndChart, // System descriptor of the chart window, where the template is loaded.
int nTemplate); // Template number in the list of templates. The templates are sorted in the list by name. The number of templates is limited to 64.

Tested it recently. It works.

 
7777877:
Right click on the smiling face (in the top right corner of the client terminal window) -> Advisors -> Remove

And how to do it programmatically, with the help of code. Did the Expert Advisor perform its function and go down?
 
Elektronik:

How do you do this programmatically, with the help of code? Did the Expert Advisor perform its function and then go down?
https://www.mql5.com/ru/forum/110207
PostMessageA(WindowHandle(Symbol(),Period()), WM_COMMAND, 33050, 0);
 
Elektronik:

And how to do it programmatically, using the code. The Expert Advisor executes its function and then shuts down?

Same library with MT4 ready control functions.

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// 7. MQL4 PROGRAM MANAGEMENT FUNCTIONS.
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// 7.1. The function deletes an Expert Advisor from the specified chart. If successful, the function returns TRUE, otherwise FALSE.
bool ServiceDeleteExpert(int hwndChart); // System descriptor of the chart window, which is deleted by Expert Advisor.
//======================================================================================
// 7.2. FUNCTION removes indicators by name from the list of loaded indicators.
void ServiceDeleteIndicatorsByName(int hwndChart, // System descriptor of the window, where the indicator is attached.
int nWindow, // Number of subwindow to delete indicators. If -1, indicators from all subwindows are removed.
string &asIndicatorName[], // One-dimensional array with names of indicators to be deleted.
int nNumberName); // Number of indicator names in the array.
//======================================================================================
// 7.3. The function removes the script from the specified chart. If it succeeds, the function returns TRUE, otherwise it returns FALSE.
bool ServiceDeleteScript(int hwndChart); // System descriptor of the chart window, the script to be deleted.
//======================================================================================
// 7.4. The function controls the script shutdown dialog box and returns the system descriptor of the script shutdown dialog box if the window exists,
// otherwise - NULL. The script works only with Russian and English localizations.
int ServiceDialogScript(int bInstruction); // Command for the script shutdown dialog window: TRUE - to shutdown the script, FALSE - not to shutdown the script.
//======================================================================================
// 7.5. The function gets indicator names from the list of uploaded indicators.
// If successful, the function returns the number of indicators in the specified subwindows using the "nWindow" parameter, otherwise it returns zero.
int ServiceGetNamesIndicators(int hwndChart, // System descriptor of the window, the indicator is attached to.
int nWindow, // Number of the subgraph. If -1, we read indicator names from all sub-windows.
string &asIndicatorName[], // One-dimensional string array for indicator names.
// The array must be initialized with different values in each cell!
This is // a peculiarity of string arrays initialization in MQL4.
int nNumberName); // Size of the "asIndicatorName[]" array for accepting indicator names.
//======================================================================================
// 7.6. The function calls the indicator list window.
bool ServiceListIndicators(int hwndChart); // System descriptor of the chart window, on which the window of the list of indicators is called.
//======================================================================================
// 7.7. The function loads a custom indicator to the specified chart by its name.
void ServiceLoadCustomIndicator(int hwndChart, // System descriptor of the chart window, where the indicator is loaded.
string szNameIndicator, // Name of the loaded indicator.
int bOK); // Confirmation of the indicator start, if the dialog window of indicator properties is present.
// TRUE - auto click on "OK" button allowed, FALSE - auto click on "OK" button disabled.
//======================================================================================
// 7.8. The function loads the Expert Advisor to the specified chart by its name.
void ServiceLoadExpert(int hwndChart, // System descriptor of the chart window, where expert is loaded.
string szNameExpert, // Name of the Expert Advisor to be loaded.
int bOK); // Confirm start of Expert Advisor, if Expert Advisor properties dialog is available.
// TRUE - "OK" button is enabled, FALSE - "OK" button is disabled.
//======================================================================================
// 7.9. The function loads to the specified chart the script by its name.
void ServiceLoadScript(int hwndChart, // System descriptor of the chart window, where the script is loaded.
string szNameScript, // Name of the loaded script.
int bOK); // Script launch confirmation, if the script properties dialog is present. The script may not have a properties dialog!
// When using the function for loading the script from the script on the current chart, the parameter does not work due to
// it is impossible for two scripts to run simultaneously on one chart.
// TRUE - "OK" button auto click is enabled, FALSE - "OK" button auto click is disabled.
//======================================================================================
// 7.10. The function loads a standard indicator to the specified chart by its name.
void ServiceLoadStdIndicator(int hwndChart, // System descriptor of the chart window, where the indicator is loaded.
string szNameIndicator, // Name of the loaded indicator.
int bOK); // Confirmation of the indicator start, if the dialog window of indicator properties is present.
// TRUE - auto click on "OK" button allowed, FALSE - auto click on "OK" button prohibited.
//======================================================================================
// 7.11. The function calls the menu of Expert properties. If it succeeds, the function returns TRUE, otherwise - FALSE.
bool ServicePropertiesExpert(int hwndChart); // System descriptor of the chart window, on which the menu of expert's properties is called.
//=======================================================================================
// 7.12. Function enabling/disabling the Expert Advisors by manipulating the Expert Advisors button.
void ServiceSetExperts();

 
Elektronik:

How do you do this programmatically, with the help of code? The Expert Advisor executed its function and then crashed?

FAQ:
h ttps://www.mql5.com/ru/forum/110207
PostMessageA(WindowHandle(Symbol(),Period()), WM_COMMAND, 33050, 0);

I don't agree. No need to go beyond mql, no need to remove the EA from the chart. It's enough to programmatically block the trade by providing for this in the EA's code.

 
granit77:

I disagree. There is no need to go beyond mql, no need to remove the EA from the chart. It is enough to programmatically block the trade by providing for this in the EA code.


Let me disagree with you (watch to the end) :

 
granit77:

I disagree. There is no need to go beyond mql, no need to remove the EA from the chart. It is enough to programmatically block trading by providing for this in the EA code.

Yes, that's right! The only exception is for remote management.
 

Do you know, please advise, there is a code section in the advisor, it is necessary to know how the previous candle closed on two pairs at the opening of a new candle, everything works fine, but if at that moment there are ticks on two pairs, the advisor is on the main pair and there are no problems with it, but if the second pair with the beginning of a new candle has no ticks, the values from it are not updated and receive data from it, not from the previous candle, but from the day before.

{//1
if (iClose(SignalSimbol,PERIOD_H1,1) > iOpen(SignalSimbol,PERIOD_H1,1)) svcolor1 = 1; // бычья свеча
if (iClose(SignalSimbol,PERIOD_H1,1) < iOpen(SignalSimbol,PERIOD_H1,1)) svcolor1 = 2; // медвежья свеча
if (iClose(SignalSimbol,PERIOD_H1,1) == iOpen(SignalSimbol,PERIOD_H1,1)) svcolor1 = 3; // додж
if (iClose(TradeSimbol,PERIOD_H1,1) > iOpen(TradeSimbol,PERIOD_H1,1)) svcolor2 = 1; // бычья свеча
if (iClose(TradeSimbol,PERIOD_H1,1) < iOpen(TradeSimbol,PERIOD_H1,1)) svcolor2 = 2; // медвежья свеча
if (iClose(TradeSimbol,PERIOD_H1,1) == iOpen(TradeSimbol,PERIOD_H1,1)) svcolor2 = 3; // додж
spread =  MarketInfo(TradeSimbol,MODE_SPREAD);
TimeBar_t = (TimeCurrent()-Time[0])/60; // время в минутах с открытия свечи
RefreshRates ();
}//1 
Reason: