[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 823

 
Tomcrafft:

Hi all!

Guys, help me out here...How do I make sure that when an order is opened from a certain level (with stop and take)

The Expert Advisor does not open a second, third, etc order. And the next order should be opened only after the first one was closed at stop or take.

First check if there is already an open order in the market, and if it is not there yet, then open it, otherwise there is no need.
 
"Clear tester cache", what is this and how do I achieve it?
 
eugggy:

Help needed: there are 2 pending orders (in different directions), when one is triggered, the other needs to be closed. The code as shown below. How to do it correctly, that there was no error with the wrong ticket number and works properly, just a couple of lines needed to put in the EA, I do not learn. Thanks in advance.



When does the variable "Tip" get value? It should after OrderSelect().

OrderSelect(Total,SELECT_BY_TICKET,MODE_TRADES);
Tip=OrderType();

if(Tip==OP_SELL)

 
eugggy:

Help needed: there are 2 pending orders (in different directions), when one triggers, we need to close the other. The code as shown below. How it should be properly drawn up that was not an error with a wrong ticket number and works properly, just a couple of lines needed to put in the adviser, I have something I can not learn. I do not know how to do it. Thank you in advance.



Check if there are market orders.

If present, check if there are any pending

If yes, delete them

 
eugggy:
I did so with a for loop, but I get a mess, OrdersTotal() returns the number of orders (2), if I subtract one, then which order will be selected: the first or the second, and then the same mess with tickets. In general, the error 4108 - wrong ticket number, and also Alert(Ticket) returns a number higher than 0, even if the EA has just been launched and there are no orders.

Make it clear whether SELECT_BY_TICKET or SELECT_BY_POS ???

Read about OrderSelect() in the help

SELECT_BY_TICKET the order numbers on the company server, for example #12345 and #12399

SELECT_BY_POS the order numbers "in the personal list", i.e. for two orders, one has #0, the other #1

 
eugggy:
If I leave it like this, will it work correctly? It seems to work, maybe some return or RefreshRates are needed, in a word will it work in real life?


No, it won't.

 

eugggy:
А нельзя ли подробнее? Нельзя))). Я имею ввиду, если сильно не придираться, где, что, неправильно и как исправить?

I did so with a for loop, but my confusion starts, OrdersTotal() returns number of orders (2), if I subtract one, then which order will be selected: the first or the second, and then the same confusion with the tickets. In general the 4108 error is wrong ticket number and Alert(Ticket) returns a number higher than 0 even if the EA has just been launched and there are no orders.



You already got your detailed answer:

Vinin :


Check if there are market orders.

If there are, check if there are pending orders.

If present, remove By successive cycles for
 
eugggy:
I would like to know more about it. No))). I mean, if you're not picky, where, what, wrong and how to fix?


I'll repeat myself.

Check that there is a market order,

If there is, check if there is a pending order.

If there is, delete it.

If anything, I will write the code tomorrow. Although, it has already been done somewhere in this topic.

 
eugggy:
I understand, but it's easy for you, two for testing, but I've tried it - it doesn't work, that's why I'm asking. As if I am a programmer with 5 years of experience. You can't))) - I'm just kidding.
post all your code here
 
eugggy:
I got the idea, but I have problems with implementation, I'm not familiar with search of orders, there is almost nothing in help, and the tutorial is not for average minds. If there is no problem, I will try to use some of MQL4 source code, or maybe you will find some books on MQL4 for an average person to comprehend.

Also, explain in your own words what the EA should do
Reason: