int h=OrdersHistoryTotal(); if (h==0 ) {Lots=Lots_i;} else { OrderSelect(h, SELECT_BY_TICKET, MODE_HISTORY);
h is a count, like 0, 1, 2... But then you use in in OrderSelect as a Ticket number. Won't work- Even if you used it as a position number, still won't work as valid positions are 0 .. OrdersHistoryTotal-1 inclusive. There is no position number OrdersHistoryTotal.
- What are Function return values ? How do I use them ? - MQL4 forum
if (WIN==1) { if (OrderLots()==LOSS)
WIN and LOSS are initially zero. If the last order is a win, then how can OrderLots() == 0 ever?if (OrderLots()==LOSS){ ... } else // if (OrderLots()!=LOSS) {
When the first If fails the second if must be true. No need to check.- it seems there is a probleme with the incrementation of losses (stop at 1 incrementation)Of course. You only process one history order, no loop, there will be only one incrementation.
What's the purpose of?
DIRECTION=DIRECTION;
1&2:
i tried many combinaison to get the right "h"(order history) despite the presence of a lag, because for the first trade there is not a valid history information.
4: it's not like this (or it's not my aim), loss is a counter of the lots that i loose, so loss must be different of 0. and in this special case : if the order after the first win is a loss then "loss" is incementing, so then i check thanks this condition.
5. you're right !!
6. i tried too, with a loop, but the difficulty is how i'll get the limt of the loop, because the aim is to count the losses and stop when i'll get 2 consecutive wins !!??
7. it's not used now, but it's will be useto get the direction (sell or buy) calculated by an indicator for example.
Thanks !!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody,
Thanks by advance.