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

 
Ihor Herasko:

That's a very strange question. It's like asking: "How do you turn on a stool with a file?

Are we going to be clever or do I have a full-fledged answer, I can reproduce a mummy too !??

What is strange about the question how to change the indicator variable with a script !??

If you can't explain how to do it, just say so!

 
Игорь:

Are we going to be clever or do I have to answer fully, I can also multiply a mummy!?

What's so strange about the question of how you can change the indicator variable with a script!

If you can't explain how to do it, just say so and that's it !

You have settings in your indicator. Why do you need to change these settings with a wash?

Is that clearer what Igor meant?

 
Игорь:

What is strange about the question of how you can change an indicator variable with a script?

That's exactly what's strange about it. To understand what exactly is strange about it, I translated the whole thing into an analogy.

The script is one programme. The indicator is another program. The variable in the indicator is a memory cell. As a result, you need to forge a memory cell (physically) and replace it with another one. This formulation of the question is naturally perplexing.

In the end, instead of explaining in more detail what you need, you take on an argument.

 
Игорь:

Please advise me!

How can I use the script to change the settings (a specific variable) of the indicator on the chart!

If this is possible a piece of code would be desirable!

There is no standard API for that, but if you really want to, you can :-)

algorithm is something like this:

- scroll through all indicators of the chart (including sub-windows) to collect the maximum information about the changed indicator (name / serial number)

- save the chart template

- expand the template to find the desired indicator

- Change the desired value

- ChartApplyTemplate

- (do not forget that all of the indicators and EAs will be reloaded, and perhaps yours will be as well, and you will probably have to copy the files through WinAPI)

in general, it is a real mess :-)

 
Игорь: Please advise me!
How can I use the script to change the settings (a specific variable) of the indicator on the chart!
If this is possible a piece of code would be desirable !!!

It's very simple, I do it often. The convenience is that the script can be assigned a key. For example, Ctrl-z to remove lines, Alt-z to show lines. See functions GlobalVariableSet() and GlobalVariableGet() attached. I got the idea from another resource (corrected by the moderator Artyom Trishkin).

Files:
xDEL.mq4  1 kb
 
STARIJ:

It's very simple, I do it all the time. The convenience is that you can assign a key to the script. For example, Ctrl-z to remove lines, Alt-z to show lines. See functions GlobalVariableSet() and GlobalVariableGet() attached. I got the idea from another resource (corrected by the moderator Artyom Trishkin).

While deleting your link to another resource, for some reason the file itself disappeared.

Can you please attach it again?

 
Artyom Trishkin: While I was deleting your link to another resource, the file itself disappeared for some reason.

Is it forbidden to link to other resources? I've seen many such links... Or is there some kind of criterion?

 
Artyom Trishkin:

While I was deleting your link to another resource, for some reason the file itself disappeared.

Please attach again.

Usually they delete materials when they are afraid and feel that they are inferior, they have competitors who cannot be beaten.

But this forum is just beyond competition and there is no reason to be afraid of something.

 
Ihor Herasko:

To start with, we do not know if an order has been opened - there are no checks on this. Therefore it makes no sense to check if a Stop Loss or Take Profit has been reached on an order which has not been opened.


I tried, but it does not work, I must be doing something wrong (

              {
                    //Цена открытия ордера
                    price=High[1]+OrderPoint*Point;
                    //Стоп лосс
                    stoploss=Low[1]-Point;
                    //Тэйк профит
                    takeprofit=price+price-stoploss;
                    //Установка отложенного ордера (с присвоением magic номера 100, чтобы потом можно было их выбрать и удалить)
                    OrderSend(Symbol(),OP_BUYSTOP,1,price,3,stoploss,takeprofit,"PinBar Buy 1H",100,0,clrGreen);
                        //Проверяет открылись ли (0 - не открылись вроде) и сколько штук открыто (в данном случае не открылись), чтобы потом выбрать (уточнить) 
                        for (int i=0; i<OrdersTotal(); i++)
                        {
                        //Выбираем все неоткрытые отложенные ордера?
                        OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
                           //Если для выбранных ордеров с magic номером 100 текущая цена ушла ниже параметра стоплосса для этого отложенного ордера, то удаляем)
                           if ((OrderMagicNumber()==100)&&(Low[0]<stoploss)) 
                           {
                           OrderDelete(100);
                           }
                        }   
                 }
 
Ihor Herasko:

That's exactly what's strange about it. To understand what exactly is strange about it, I translated the whole thing into an analogy.

A script is one programme. An indicator is another programme. The variable in the indicator is a memory cell. As a result, you need to forge a memory cell (physically) and replace it with another one. This formulation of the question is naturally perplexing.

In the end, instead of explaining in more detail what you need, you take on an argument.

Thank you and that's it

Reason: