I am trying to put together an EA but have a few issues. I can only get the EA to open buy orders. I am unable to placea stoploss due to error 130m so i tried ordermodify. I am new to coding my own ea so I am struggling with this. Can anyone have a look and point out my errors and how to fix them.
StopLoss and TakeProfit levels cannot be too close to the market. The minimal distance of stop levels in points can be obtained using the MarketInfo() function with MODE_STOPLEVEL parameter. In the case of erroneous or unnormalized stop levels, the error 130 (ERR_INVALID_STOPS) will be generated.
At placing of a pending order, the open price cannot be too close to the market. The minimal distance of the pending price from the current market one in points can be obtained using the MarketInfo() function with the MODE_STOPLEVEL parameter. In case of false open price of a pending order, the error 130 (ERR_INVALID_STOPS) will be generated.
Applying of pending order expiration time can be disabled in some trade servers. In this case, when a non-zero value is specified in the expiration parameter, the error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated.
On some trade servers, the total amount of open and pending orders can be limited. If this limit has been exceeded, no new order will be opened (or no pending order will be placed) and trade server will return error 148 (ERR_TRADE_TOO_MANY_ORDERS)
Here is a part of Help guide code:
Print("Minimum Stop Level=",minstoplevel," points");
//--- calculated SL and TP prices must be normalized
ticket=OrderSend(Symbol(), OP_BUY, Lots, Ask, 10, StopLoss, Bid+TakeProfit*Point());
OrderModify ( ticket , 0 , Bid-3*StopLoss*Point, Bid+3*TakeProfit*Point,0);
To add comments, please log in or register