Questions from Beginners MQL4 MT4 MetaTrader 4 - page 237

 
Sergey Likho:

The indicator from MT5 draws a line in two colours.

The values of the line are in the same buffer.

Is there any way to identify the colour of the line when requesting values from the indicator?

You can. The colour of the line is stored in the colour buffer. If there is only one line, the value buffer is 0 and the colour buffer is 1. Accordingly, in CopyBuffer you put the second parameter 1.
 
Ventura:

If the parameter window cannot be displayed programmatically, please advise whether the parameters can be initialised in any way

input double BuyStop=100;
double MyBuyStop=BuyStop;


.........
if(something) MyBuyStop=200;
 
Евгений:

What do you recommend?

First the warrants have to be sifted by symbol and magician. You are left with two orders. You select the one you want to delete on your condition. You delete one and change the stop loss.

 
Aleksei Stepanenko
input double BuyStop=100;
double MyBuyStop=BuyStop;


.........
if(something) MyBuyStop=200;

Alexey, I asked for a suggestion on how to call the parameter calculation function BEFORE the parameter window appears, not after.

The question is open: is it possible to call the parameter window PROGRAMMatically ? If not, is it possible to initialise parameters from a function BEFORE the parameter window appears.

I would like to do something like this

input double BuyStop = GetMyBuyStop();

But I get an error saying that only constant can be on the right side (

 
Ventura:

Alexey, I asked for a suggestion on how to call the parameter calculation function BEFORE the parameter window appears, not after.

The question is open: is it possible to call the parameter window PROGRAMMatically ? If not, is it possible to initialise parameters from a function BEFORE the parameter window appears.

I would like to do something like this

input double BuyStop = GetMyBuyStop();

But an error occurs that there can only be a constant on the right (

There is nothing before parameter window appears, everything begins only later, when the window is already loaded

 

Exactly what Vitaly said!

Create a panel on the graph, manage the variables from there.

 
Vitaly Muzichenko:

There is nothing before the parameters window appears, it only starts afterwards, when the window is already loaded

I know this, that's why I'm waiting for professional advice. Maybe it can be done by non-standard means, through Win API or something else.

Is there really no way to show the window programmatically, from the code?

 
Ventura:

I know this, that's why I'm waiting for professional advice. Maybe it can be done by non-standard means, through Win API or something else.

Is there no way to show the window programmatically, from the code?

Before the initialization of the EA (and the parameters are entered before the initialization), the EA is not available, it does not work... Before the initialization of the Expert Advisor, the window of its parameters is available to you. But it does not suit you. So, use another input of the values you need - after the initialization of the EA. You have access to the MessageBox() window. But it will not help you much - there are no value entry fields - just agree/disagree/cancel buttons.

So - you need to use your own window. You can create it yourself from objects. Look for it in ObjectCreate(). Or use Canvas. But kanvas is not for simple crafts.

Документация по MQL5: Графические объекты / ObjectCreate
Документация по MQL5: Графические объекты / ObjectCreate
  • www.mql5.com
ObjectCreate - Графические объекты - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin:

The EA is not available before it is initialised (and the parameters are entered before initialisation), it does not work... Before the EA is initialised, its parameters window is available to you. But it does not suit you. So, use another input of the values you need - after the initialization of the EA. You have access to the MessageBox() window. But it will not help you much - there are no value entry fields - just agree/disagree/cancel buttons.

So - you need to use your own window. You can create it yourself from objects. Look for it in ObjectCreate(). Or use Canvas. But kanvas is not for simple crafts.

Artem, thank you, I was waiting for your advice. While waiting, I was looking for possible solutions myself. This morning I worked out how to show settings window programmatically !

I found that the window is called by pressing F7. A search on the Internet has shown that MQL can be used to make a soft keypress.

The rest is a matter of technique. Here is the code that may be of use to someone:

extern double BuyStop, SellStop;

...

void SetParams()
  {
   BuyStop = CalcBuyStop();
   SellStop = CalcSellStop();
   int handle = WindowHandle(Symbol(), 0);
   PostMessageA(handle,WM_KEYDOWN,VK_F7,0);
  } 
 

But I rejoiced too early. I managed to open the parameter window programmatically, but the values I assigned to the parameters in the procedure were not saved (((

That is, when I open the parameter window, I see the values specified during initialization, in my case zeros.

Is there any way to make the calculated values transferred to the parameter form ?

Reason: