How to add option to close every trade at the end of the month or week.
A simple code closing all orders on Friday at 21:00
//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- ... if (DayOfWeek() == 5 && TimeHour(TimeCurrent())>=21) CloseAllOrders(); } //+------------------------------------------------------------------+ //| Close all active orders | //+------------------------------------------------------------------+ void CloseAllOrders() { int i=OrdersTotal()-1; while (i >= 0) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 10)) { Print("Order Close Error: "+IntegerToString(GetLastError())); } } i--; } }
Sorry but i really don't know anything about coding, could you write the full code to paste into the EA code?
Thanks.
No because you would not know where to insert it.
But your free personal coder has arrived so now @Janusz Trojca is going to help you solve the issues.No because you would not know where to insert it.
But your free personal coder has arrived so now @Janusz Trojca is going to help you solve the issues.I'm nobody's free personal code. I only shared a piece of code that is full on the web. Nothing special. Is this something bad?
Nothing bad,on the contrary thank you so much !
Now please help the Unexpected Reporter to a working solution.
Nothing bad,on the contrary thank you so much !
Now please help the Unexpected Reporter to a working solution.
He will be back with more questions for you just wait a bit.
Do you have a headache ?
Hi everybody,
I have an EA i'm working on it and i would like to add an option to close every trade at the end of the week or at the end of the month.
How can i do it?
I literally have 0 experience on mq4 coding.
Thanks.