[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 1050

 

How do I write the condition if(ordershistorytotal()"replenished by one order")?

 
Stasjan:

How do I write the condition if(ordershistorytotal()"replenished by one order")?

For this, the previous value of OrdersHistoryTotal() must be stored in a static variable, and the previous and current values must be compared in the condition. If it has changed, then it has replenished, since the values don't change in a smaller direction there.
 
Reshetov:
To do this, the previous value of OrdersHistoryTotal() must be stored in a static variable, and the previous and current values must be compared in the condition. If it has changed, then it has replenished, since the values do not change downwards there.

thanks!!!
 
prom18:
Please, help. The Expert Advisor puts two pendants BuyStop and SellStop by the signal. There is also a signal to open a Buy pending order. I have to modify an old Buy order by conditions of the last signal. I did it through the OrderModify() function. It didn't work. It gives us an error 4051. How to select the required order. I understand that we should choose the ticket, but how to determine the ticket of the required order (in this case, we are dealing with BuyStop). Explain at least the logic of action. Thank you!

int ticket = -1;

...

OrderSelect(...);

if (OrderType() == OP_BuyStop) {

ticket = OrderTicket();

OrderModify(...);

return(0);

}

 
Reshetov:
To do this, the previous value of OrdersHistoryTotal() must be stored in a static variable, and the previous and current values must be compared in the condition. If it has changed, then it has replenished, since the values do not change downwards there.

Any advice on how to make it the same?
 
Roman.:

1 is certainly not much. A lot depends on the broker's speed of executing your orders, depends on the speed (from the internet) you give your orders to the broker, probably also on "something" on the real account that we (I) are not aware of. Slava wrote, how the broker cut his pipsaur (by means of so called "individual approach" to a client) increasing a minimum dist from 2,3 points to 18 - 20 points, see a branch here https://forum.mql4.com/ru/37451/page10...
I put 2 points to "buffer" - all trades are opened now ) Thanks again.
 
Stasjan:

Any tips on how to reset it?

static prevhitorytotal = 0;

...

if (OrderHistoryTotal() != prevhistorytotal) {

// replenished by one order

}

prevhistorytotal = OrderHistoryTotal();

 
Reshetov:
For this purpose, the previous value of OrdersHistoryTotal() must be stored in a static variable, and the previous and current values must be compared in the condition. If it has changed, then it has replenished, since the values there are not changed downwards.


static int totalh=OrdersHistoryTotal();

if(OrdersHistoryTotal()>totalh)

have I understood correctly or not?

 
Reshetov:

static prevhitorytotal = 0;

...

if (OrderHistoryTotal() != prevhistorytotal) {

// replenished by one order

}

prevhistorytotal = OrderHistoryTotal();


Got it?

 
Stasjan:


static int totalh=OrdersHistoryTotal();

Incorrect.

static int totalh=0; // static variables are declared before calls start(), init() and deinit()

...

int start() {

...

if (OrderHistoryTotal() != totalh) {

// replenished by one order

}

totalh = OrderHistoryTotal();

...

}