Your English is very good . . . .
I'm happy to try and help you but I won't code for you . . .
In an EA you can add a delay using Sleep https://docs.mql4.com/common/Sleep
To keep track of your daily profit/loss one way is to look through your orders placed and closed during the day (check the order open time and closed time) and sum the OrderProfit of all the trades, https://docs.mql4.com/trading/OrderProfit make sure you use the History pool ( https://docs.mql4.com/trading/OrderSelect MODE_HISTORY)
Also look here: http://crum.be/1e
- Sleep doesn't work in the tester
- You can't trail stops if you sleep
- put a delay (in hours ou minutes) between trades
static datetime nextTrade; if (nextTrade < TimeCurrent() /*or Time[0]*/){ int ticket = OrderSend if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else nextTrade = TimeCurrent() + 4*3600; // next trade in 4 hours. }
what I want is that when a trade is closed, it opens after 4 hours.
static datetime lastClose; datetime lastClosePrev = lastClose; for(int pos=0; pos < OrdersHistoryTotal(); pos++) if ( OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/ && OrderCloseTime() > lastClosePrev // not yet processed, && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() // and my pair. && OrderType() <= OP_SELL){// Avoid cr/bal forum.mql4.com/32363#325360 lastClose = OrderCloseTime(); } if (Time[0] < lastClose + 4*3600) return;
THANK YOU VERY MUCH I LOVE U ! lol =)
I have another problem lol, I do not know why, but with this code, "OrderSend" and "OrderClose" does not work anymore, it no longer satisfies the conditions : /
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Sorry for my English, I am French, I hope you understand me.
I could not find a similar topic on the forums French, so I hope you can help me.
My EA is taking a new position on the same bar at each end of trade, and I would put a delay (in hours ou minutes) between trades.
Can you look at my code and correct it?
Then I wonder if it was possible to put a profit target per day?
For example: "if you win 100 euros, stop"?
I give you my code and hope you can help me.
thank you very much
int NumPos;
for (int i = 0; i < OrdersTotal (); i++) {if (OrderSelect (i, SELECT_BY_POS, MODE_TRADES) == False){
break;
return (0);
}
NumPos++;
}
// -- Signal Stop SELL --
if ( (Sell1_3 > Var3 && Sell1_2 > CloseSell1_3 )&& (Sell1_4 >=0 )) {
OrderClose (OrderTicket (), OrderLots (), Ask, 1, Red);
}
//-- Signal SELL --
if (!NumPos && Sell1_1 > Sell1_2 && Sell1_3 < Var3 && Sell1_4 < Var4){
OrderSend (Symbol (), OP_SELL, 0.1, Bid, 3, Bid + 500 * Point, Bid - 500 * Point, "Vente", 123456, 0, Red);
}