Invalid Stop

 

This is my Code to Buy in my expert, On BCTUSD it gives back error message of invalid stops, Why?


//+------------------------------------------------------------------+
//| Expert DO_Buy function                                 |
//+------------------------------------------------------------------+
void Do_Buy(double PriceForBuy){

   bool Buy_Opened=false;
   bool Sell_Opened=false;
   if(PositionSelect(_Symbol)==true){
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) Buy_Opened=true;  //It is a Buy
   }
   if (Buy_Opened==true)return;
   
   double BuyStop,BuyTake;
   BuyStop=(PriceForBuy-STP);//STP is 3.0
   BuyTake=(PriceForBuy+TKP);//TKP is 2.0
   if(!trade.Buy(MyLot,_Symbol,PriceForBuy,BuyStop,BuyTake,"Buy By Expert"))Print("Buy() failed. Return code=",trade.ResultRetcode(),". Code description: ",trade.ResultRetcodeDescription());
   else  Print("Buy() executed . Return code=",trade.ResultRetcode()," (",trade.ResultRetcodeDescription(),")");
}


2020.05.10 12:38:34.137 CTrade::OrderSend: market buy 0.01 BTCUSD sl: 8895.645 tp: 8900.645 [invalid stops]
2020.05.10 12:38:34.836 Buy() failed. Return code=10016. Code description: invalid stops
 
Boobwood:

This is my Code to Buy in my expert, On BCTUSD it gives back error message of invalid stops, Why?


When I changed STP to 30 And TKP to 20 It Works. Is there any Minimum Stop Loss and Take Profit?

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 
Boobwood:

When I changed STP to 30 And TKP to 20 It Works. Is there any Minimum Stop Loss and Take Profit?

every security (symbol) provided by a broker will have a specification setting out the valid parameters for trading including, min/max size, step in size, minimum SL and TP distances from current price - these will often be referred to as freeze level, stops level etc.  

right click the symbol in Market Watch and choose specification to see the values, you can also get them through MQL5  https://www.mql5.com/en/docs/marketinformation

Documentation on MQL5: Market Info
Documentation on MQL5: Market Info
  • www.mql5.com
Market Info - Reference on algorithmic/automated trading language for MetaTrader 5
 
Paul Anscombe:

every security (symbol) provided by a broker will have a specification setting out the valid parameters for trading including, min/max size, step in size, minimum SL and TP distances from current price - these will often be referred to as freeze level, stops level etc.  

right click the symbol in Market Watch and choose specification to see the values, you can also get them through MQL5  https://www.mql5.com/en/docs/marketinformation

Thank you very much

I checked the specification, but there is not any information about Stop loss and take profit values, or I did not find it. 


 
Boobwood:

Thank you very much

I checked the specification, but there is not any information about Stop loss and take profit values, or I did not find it. 


It’s the stops level. Which is showing 0  probably because it is dynamic and because the market is closed it currently is zero
 
Boobwood:

Thank you very much

I checked the specification, but there is not any information about Stop loss and take profit values, or I did not find it. 


No t

Paul Anscombe:
It’s the stops level. Which is showing 0  probably because it is dynamic and because the market is closed it currently is zero

No the market is open.

if stop loss must be 0 then how I could a sell position with STP=30 and TKP=20 via my Expert?

 
Boobwood:

No t

No the market is open.

if stop loss must be 0 then how I could a sell position with STP=30 and TKP=20 via my Expert?

Have you normalised the sl tp prices before you submit them?  I don’t see that in your code

And you can check current stop levels using MarketInfo
 
Boobwood:

No t

No the market is open.

if stop loss must be 0 then how I could a sell position with STP=30 and TKP=20 via my Expert?

stoploss must be greater than stoplevel 

 
Ahmet Metin Yilmaz:

stoploss must be greater than stoplevel 

stopllevel is 0 (in the symbol specification) o any value more than 0 is accepted. is n't it?

 
Paul Anscombe:
Have you normalised the sl tp prices before you submit them?  I don’t see that in your code

And you can check current stop levels using MarketInfo

I did but nothing changed.

 
Boobwood:

stopllevel is 0 (in the symbol specification) o any value more than 0 is accepted. is n't it?

yes

and it was for your question below

Boobwood:

if stop loss must be 0 then how I could a sell position with STP=30 and TKP=20 via my Expert?

STP=30 and TKP=20 both greater than zero " 0 ".

Reason: