Hi
just wondering if anyone can help me with this. I just keep getting error 130 when i run this. I looked on the mql4 website and says the code is a due to invalid stoploss value. I looked through the code many times but see no error in the logic. Also, the function eventually manages to produce a valid ordermodify but only after 20-40 error 130s. if anyone could tell me what i did wrong, I really appreciate it.
Thanks
this will try to set a stop level at Price + (5+1)pips + 2pips, i.e. 8 pips away from the order open price, while many currency pairs have wider stop level requirements. Also, if there is enough time elapsed between when you opened the order and are trying to set the stop levels, the current Bid/Ask could be significantly different from your OrderOpenPrice().
you can check this, for example,
if (OrderType == OP_SELL) {
if ( MarketInfo(Symbol(), MODE_STOPLEVEL) >
MathAbs( Bid - Your_new_SL_price) )
{
stop loss is too close; widen the gap;
}
}
similarly, OP_BUY will be
if (OrderType == OP_BUY) {
if ( MarketInfo(Symbol(), MODE_STOPLEVEL) >
MathAbs( Ask - Your_new_SL_price) )
{
stop loss is too close; widen the gap;
}
}
if (OrderType == OP_SELL) {
if ( MarketInfo(Symbol(), MODE_STOPLEVEL) [B]* Point[/B] >
MathAbs( Bid - Your_new_SL_price) )
{
stop loss is too close; widen the gap;
}
}
similarly, OP_BUY will be
if (OrderType == OP_BUY) {
if ( MarketInfo(Symbol(), MODE_STOPLEVEL) [B]* Point[/B]>
MathAbs( Ask - Your_new_SL_price) )
{
stop loss is too close; widen the gap;
}
}