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

 
Alexey Viktorov:

Sometimes this is exactly the case, of that I am aware... But in this case, after the suggestion to do not a script, but an advisor, this is what the answer is...


I've already lost the essence of the question. What was the initial task? Why is there no interaction between indicators and EAs and scripts, everything is there, but the mechanism is rather complicated, I have an arbitrage EA that works this way.

 
Galim_V:

Thank you, Igor. So the terminal does not leave any checkboxes for the program? And if I don't want to search for orders at every tick, I have to invent conditions for that?

Well, it's a matter of imagination, look through the examples of Expert Advisors in Codobase.

Historically, we have developed the following scheme for Expert Advisors: On every tick, an EA will do

1. order recalculation

2. call indicators

3. close and open orders

4. print the information to the log or to the screen

In theory, this EA structure allows you to get back to work after a connection failure and after a restart of the terminal; in principle, the performance of MQL is very good right now.

you can use global variables of the program with the static modifier as flags, but in this case you have to think through how to act in case of a connection failure or restart of the terminal

look at ready examples and try to modify them to suit your needs, if you understand them, write the Expert Advisor code as you see fit

https://www.mql5.com/ru/code/mt4/experts

HH: as an alternative you can try to work with different magic numbers of orders, i.e. you put a pending order, then control market orders with this magic, then a new pending order with a new one.... I do not even remember if the ticket of a pending order is changed when it becomes a market one, probably not - we should check it, it is also possible if the tickets are the same, i.e. we memorize the ticket for a pending order and then look for this ticket for a market order. But in my opinion, it would only complicate the implementation and we would need to think about how to restart the terminal... It's not worth the trouble, it's easier to re-calculate the order on each tick

MQL5 Code Base: Советники
MQL5 Code Base: Советники
  • www.mql5.com
Сеточный советник "Поворот паука" заданным объемом открывает начальный ордер со скрытыми СЛ и ТП. При срабатывании СЛ открывается противоположный ордер таким же объемом и СЛ, но ТП ордера увеличивается на размер убытка предыдущего ордера. Так позиция переворачивается пока не закроется по ТП. При уходе цены в прибыль, на определенных условиях...
 
Igor Makanu:

well, it's a matter of imagination, look at the examples of EAs in kodobase

Historically, we have developed the following scheme for Expert Advisors: on every tick an Expert Advisor will do

1. order recalculation

2. call indicators

3. close and open orders

4. print the information to the log or to the screen

In theory, this EA structure allows you to get back to work after a connection failure and after a restart of the terminal; in fact, the performance of MQL is very good right now, you can work according to this scheme = seemingly no extra actions on every tick, but guaranteed to work after the restart

you can use global variables of the program with the static modifier as flags, but in this case you have to think through how to act in case of a connection failure or restart of the terminal

Let's put it this way, first look at ready-made examples, then try to modify them to suit your needs, if you understand them, write the Expert Advisor code as you see fit

https://www.mql5.com/ru/code/mt4/experts

Thanks for the detailed reply.

 
Vitaly Gorbunov:

I've already lost track of my question. What was the original task? Why is there no interaction between indicators and scripts, everything is there, but the mechanism is quite complicated, I have an arbitrage EA that works that way.

It is true... What was the initial task? I don't remember either...:)))))))))))

 
Alexey Viktorov:

Really... What was the original task? I don't remember either...:)))))))))))


neverness:

I have the following question.

Run the terminal and an arbitrary quote chart on it. For example EUR/USD.

Attach a certain indicator to this chart. For example, an SMA indicator.

Run a script on this chart. For example a script that builds an ellipse ELLIPSSCRIPT.

Questions:

How to export values from the SMA indicator to ELLIPSSCRIPT ?

For example, how to export values of four ellipse coordinates (time, quote, time, quote) from an indicator into a script ?

Can I export array values and how to do it ?

How to describe exported values in indicator properties and how to describe imported values in script properties ?

 
Igor Makanu:

with different magic numbers, i.e. you place a pending order, then control market orders with that magic number, then a new pending order with a new magic number .... I do not even remember if the ticket of a pending order is changed when it becomes a market one, probably not - we should check it, it is also possible if the tickets are the same, i.e. we memorize the ticket for a pending order and then look for this ticket for a market order. But in my opinion, it would only complicate the implementation and we would need to think about how to restart the terminal... Well, it's not worth the trouble, it's easier to re-calculate the order on each tick.

The number of the ticket does not change. The profit or loss appears). It was important for me not to look for a black cat in a dark room when it's not there. Thank you very much.

 
Igor Makanu:


Yeah.

And what prevents you from drawing this ellipse in the indicator itself

without exporting...... import....

 
Igor Makanu:


Exactly!!!!!

neverness:

I have the following question.

Run the terminal and an arbitrary quote chart on it. For example EUR/USD.

Attach a certain indicator to this chart. For example, an SMA indicator.

Run a script on this chart. For example a script that builds an ellipse ELLIPSSCRIPT.

Questions:

How to export values from the SMA indicator to ELLIPSSCRIPT ?

For example, how to export values of four ellipse coordinates (time, quote, time, quote) from an indicator into a script ?

Can I export array values and how to do it ?

How to describe the exported values in the indicator properties, and how to describe the imported values in the script properties ?

And then the question moves on to another plane... The script is "run and let it wait for the indicator to give the command" .......

How can I give a sensible tip to such a programmer????

Although, here, after several days of discussion he has it....

Forum on trading, automated trading systems and trading strategies testing.

Any questions from newbies about MQL4, help and discussion of algorithms and codes

Alekseu Fedotov, 2018.09.13 19:49

Yeah.

And what prevents you from drawing this ellipse in the indicator itself

Without export...... import....

But... I don't think anyone wants him anymore.
 
Alexey Viktorov:

Exactly!!!!!

what can i say? as they say: the right question is half the answer

i tried to explain the difference between a script, an indicator and an Expert Advisor. i know that data can be taken from indicator buffers and graphic objects can be taken from an object name or by trying all objects and the data exchange is performed either through a file or global variables of the terminal. then they started to explain that there are global variables of MQL-program and global variables of the terminal and they even couldn't help me to read the help .... it's in russian!!! - It's hard to do without help in russian - I started working with Matlab a couple of months ago and it's so hard to get it right on the web - you just have to read it all the time.

 
The goal must justify the means. If you have the source code of all the necessary components, it is easier to combine everything in one EA. If this is not possible, it is necessary to organise communication between the modules of all the components, but this is not a task for beginners.
Reason: