what happens if my ea opens a position (with a stop loss) on friday and it's still open after the broker shuts the service?
From friday 10pm to monday morning my metatrader chart is dead, is it ok if my position is still open or should I close it before 10pm?
That rather depends on how sophisticated your EA is. In reality, your position will be held over the weekend and will still be there when the market re-opens the following week. Whether your EA still knows about it depends on several factors, including whether or not you shut MetaTrader down over the weekend, whether or not your EA is equipped to tell by looking at open positions whether or not it has a position it is supposed to be managing, and whether or not your EA contains any code to keep track of what it is doing when it is shut down and restarted.
All EAs I code for other people or for deployment live contain code to store their internal state so they can recover if they are shut down, either due to an MT crash, or weekend maintenance. But that doesn't happen automatically; if the person who your your EA didn't put it in, it doesn't have it.
I coded my ea, metatrader is always on during weekends (it runs on a vps), the ea doesn't close any order just sets tp and sl, I wonder if that is safe over weekends I mean since the position is open on the broker server if the price reaches the stop loss on saturday will the order be closed?
(I don't have any mechanism for shutdown recovery, it's very tedious to code that stuff, I have a lot of parameters in many ea's on the same mt4 client).
Ok, I understand my ea will lose control of a trade is there's a crash, but if the order was open with a stop loss I guess the position will be closed if the price reaches the stoploss level even in case of a a crash or if it's saturday and my terminal is dead. So I can lose only by a stoploss amount, is that right? I'm scared by your 200 pips example, again if my stoploss is at 40 pips why 200?
I don't store any ticket number in a variable but always call OrdersTotal/OrderSelect to retrieve the last position from the server (I allow only one open position per ea).
Thanks for you reply.
That's a bummer. I can't afford to let a position open over the weekend, I gotta close 'em all before the weekend starts then.
I wonder how people manage to let positions open over a long period of time like days or weeks.
By the way, it's so difficult to find good reliable information on this topic, I guess all we have is the mt4 book/reference on the website, is there anything else?
Don't mix up MetaTrader and EA programming with trading and the market.
You don't find detailed informations how the market works and how to trade on this forum.
To add comments, please log in or register