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

 
Sergey Gritsay:

There are plenty of examples in CodeBase, look for Expert Advisors on pending orders and see how the code is written.

I searched throughCodeBase for about an hour and did not find anything understandable. It is too complicated for me. The codes are too large and incomprehensible for me, while all I need is a couple of codes 4-6 lines long. Thanks for the reply, but it doesn't fit.
 
maxon777:

I searched for a sample ina pending order when it has reached any value (i.e. if the price is 0.7777, then open a pending order)

2) Close the order (market order) when it has reached any value (i.e. if the price is 0.6666, then close the order).

Get an answer to 4-6 lines of code?

Are you one of those customers who write, "What is there to do? It only takes a couple of lines... What's a hundred quid?"

Let's be clear:

You have to first determine that the price has reached 0.7777. Did it reach the top? Bottom? Is it OK if the previous tick was, for example, 0.7776 and the current tick has become 0.7778 ? In this case, the price will not equal the value of 0.7777. So, you must check the past value and the current one for intersection of the needed value. Correspondingly, you must store the value of the previous tick and know the value of the current tick. It means - you need a function for getting the value of the tick and storing its value, so that you will have something to compare it with later - three prices: the previous tick, the current tick and the crossed price itself.

Further. We need to know in which direction the price will cross the necessary value and, correspondingly, we need to set the necessary type of pending order at the necessary price.

To set it, we need to calculate the price set from the current price, compare the obtained distance of the pending order setting with the StopLevel value and if the obtained distance is less than that value, then: a) Correct the order setting distance so as not to reach error 130 and set the order or b) wait until the setting distance exceeds the StopLevel (with the floating spread which we should also receive on every tick) and see if the price already crosses the preset level and if it is on the correct value - i.e. if the StopLevel is already set, we can set the order.е., it has moved away from that level to place an order or the train has already left.

You also need to calculate stop and take values of a pending order which must not be less than StopLevel (correct them if necessary).
If all the checks have been passed, an order should be sent to the server to set a pending order, get a reply - if the reply contains an error, process it (another function is needed)...

This is for pending orders.

It is approximately the same for closing a position - identify the crossing, send a trade order and handle the server's response in case of error.


If you manage to fit in 4-6 lines for all this, then ...you will get a medal in the warehouse... ;)

 
I feel that after this explanation there is one less novice programmer ))))
 
Andrey Koldorkin:
I feel that after this explanation there is one less novice programmer ))))
 

Guys, what the (.e) in valuta is please explain

 
the code section you need is a reliable multicurrency trailing stop that starts with a set break-even point and a set step back from the price
 
Vitaliy29:
you need a code section - a reliable multicurrency trailing stop that starts with a set break-even point and a set indent from the price

Check out this one, http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=62

Автоматизация торговли на финансовых рынках - Скачать e-Trailing2.rar
  • www.kimiv.ru
Оглавление файлового архива  Разработки на MQL4 Советники   Новая улучшенная бесплатная версия "кимовского трала". Добавлен параметр Magic, позволяющий более гибко отбирать сопровождаемые позиции, а также разделены параметры трала для покупок и продаж. Кроме того, вместо параметра ProfitTrailing теперь используется TrailingStart. Это почти то...
 
Artyom Trishkin:

You want to answer this question:

1) open a pending order when it has reached any value (i.e. if the price is 0.7777, then open a pending order)

2) Close the order (market order) when it has reached any value (i.e. if the price is 0.6666, then close the order).

Get an answer to 4-6 lines of code?

Are you one of those customers who write, "What is there to do? It only takes a couple of lines... What's a hundred quid?"

Let's be clear:

You have to first determine that the price has reached 0.7777. Did it reach the top? Bottom? Is it OK if the previous tick was, for example, 0.7776 and the current tick has become 0.7778 ? In this case, the price will not equal the value of 0.7777. So, you must check the past value and the current one for intersection of the needed value. Correspondingly, you must store the value of the previous tick and know the value of the current tick. It means - you need a function for getting the value of the tick and storing its value, so that you will have something to compare it with later - three prices: the previous tick, the current tick and the crossed price itself.

Further. We need to know in which direction the price will cross the necessary value and, correspondingly, we need to set the necessary type of pending order at the necessary price.

To set it, we need to calculate the price set from the current price, compare the obtained distance of the pending order setting with the StopLevel value and if the obtained distance is less than that value, then: a) Correct the order setting distance so as not to reach error 130 and set the order or b) wait until the setting distance exceeds the StopLevel (with the floating spread which we should also receive on every tick) and see if the price already crosses the preset level and if it is on the correct value - i.e. if the stop level is set, we can set the order.е., it has moved away from that level to place an order or the train has already left.

You also need to calculate the Stop and Take values for the pending order which in their turn should not be lower than the Stop Level (correct them, if necessary).
If all the checks have been passed, an order should be sent to the server to set a pending order, get a reply - if the reply contains an error, process it (another function is needed)...

This is for pending orders.

It is much the same for closing a position - identify the crossing, send a trade order and handle the server's response in case of an error.


If you manage to fit in 4-6 lines for all this, then ...you will get a medal in the warehouse... ;)

"You're the kind of customer who says "What's there to do? It's just a couple of lines... What's a hundred quid?" No, I'm not one of those people, and I don't understand why you think I'm a customer. I want to learn this program because I have ideas about the Expert Advisor, the problems in its implementation are only technical (and I'm not disputing that the problems are very big), but I'm not trying to say something like "make me all the software and that it works only with profit. On the contrary, I started with basics and I want to write my first Expert Advisor. I also wrote that I wanted a very simple example, without taking into account all the details (even though I understand that they are very important), but I have to start somewhere. I knew that it would be painful for a professional to look at what I'm asking, but I couldn't help it, as long as it's all I know. I thought I could write such a piece of code with help of if else operator and OrderSend (OrderClose) function and some other things, which I can't do. You have written a lot of complex terms and thus told me that I'm unable to do anything and am an idiot in programming, but I know it anyway. I hope you don't think I am an arrogant man and understand that I just want to continue learning. But you are right too, I hope a compromise has been found.
 
maxon777:
"You're the kind of customer who says, "What's there to do? It's just a couple of lines... What's a hundred quid?" No, I'm not one of those people and I don't understand why you think I'm a customer. I want to learn this program because I have ideas about the Expert Advisor, the problems in its implementation are only technical (and I'm not disputing that the problems are very big), but I'm not trying to say something like "make me all the software and that it works only with profit. On the contrary, I started with basics and I want to write my first Expert Advisor. I also wrote that I wanted a very simple example, without taking into account all the details (even though I understand that they are very important), but I have to start somewhere. I knew that it would be painful for a professional to look at what I'm asking, but I couldn't help it, as long as it's all I know. I thought I could write such a piece of code with help of if else operator and OrderSend (OrderClose) function and some other things, which I can't do. You have written a lot of complex terms and thus told me that I'm unable to do anything and am an idiot in programming, but I know it anyway. I hope you don't think I am an arrogant man and understand that I just want to continue learning. But you are right too, I hope a compromise has been found.

No one called you a "sucker", that's not true. But also 4-6 lines of code, you know, cause bewilderment - because if a person learns something, he must already be trying something, he has already tried to write something, and clearly sees that 4-6 lines do not fit into it.

Show us what you tried to do - let's try to understand.

I can propose an alternative, simplified version - do not look for a price level crossing by ticks, and look for it by MA(1) - then the MA on bar 1 and MA on bar 0 will serve as an indicator of the necessary level crossing.

 
Sahet.Sh:

Guys, what the (.e) in valuta is please explain

This is a question for the broker, feel free to contact support. Only he knows exactly what his .e suffixes mean. It's his decision. In general, suffixes (also prefixes) in names of currency pairs and other instruments can mean anything: ie - instant execution, m - market execution, dot - five digits in quotation and commission, _OP - instrument for trading binary options,... But of course, it is only the broker's decision, he is the final authority in finding out the meaning of the designations he has introduced.