Takeprofit and Stoploss in LibOrderReliable_V1_1_4.mq4

 

I've been using LibOrderReliable_V1_1_4 for some time, but recently found a discrepancy which I am not sure about. Thought u guys might help me out. The functions that validate proper stoploss and takeprofit levels are called OrderReliable_EnsureValidTP() and OrderReliable_EnsureValidSL(). Here they are:


//=============================================================================
void OrderReliable_EnsureValidSL(string symbol, double price, double& sl)
{
// Return if no S/L
if (sl == 0)
return;

double servers_min_stop = MarketInfo(symbol, MODE_STOPLEVEL) * MarketInfo(symbol, MODE_POINT);

if (MathAbs(price - sl) <= servers_min_stop)
{
// we have to adjust the stop.
if (price > sl)
sl = price - servers_min_stop; // we are long

else if (price < sl)
sl = price + servers_min_stop; // we are short

else
OrderReliablePrint("EnsureValidStop: error, passed in price == sl, cannot adjust");

sl = NormalizeDouble(sl, MarketInfo(symbol, MODE_DIGITS));
}
}
//=============================================================================
void OrderReliable_EnsureValidTP(string symbol, double price, double& tp)
{
// Return if no S/L
if (tp == 0)
return;

double servers_min_stop = MarketInfo(symbol, MODE_STOPLEVEL) * MarketInfo(symbol, MODE_POINT);

if (MathAbs(price - tp) <= servers_min_stop)
{
// we have to adjust the stop.
if (price < tp)
tp = price + servers_min_stop; // we are long

else if (price > tp)
tp = price - servers_min_stop; // we are short

else
OrderReliablePrint("EnsureValidStop: error, passed in price == tp, cannot adjust");

tp = NormalizeDouble(tp, MarketInfo(symbol, MODE_DIGITS));
}
}
//=============================================================================


What I don't understand is why they check Abs(price-tp)<=stoplevel. For example: for placing a BUY order we would be using price = ASK, but stoplevel limitation is on BID!!! If we look at "Requirements and Limitations in Making Trades" (https://book.mql4.com/appendix/limits) it specifically says that for BUY the limitation on Takeprofit is (TP-Bid) StopLevel... And we find the same descripency with SL and TP for both BUY and SELL operations. So in this example if I set the TP too low, the library would fix it at Ask+stoplevel, but if it is above Bid+stoplevel then there should be no problem with that and no reason for LibOrderReliable to fix it.


So who's right? The library or the MQL4 book?

 

Anyone?