"Invalid stops" while testing an expert advisor

 
Hi fulks, I'm starting to learn how to write expert advisors and I have the following question:

If I send a new order, where I do not specify either the Takeprofit or the StopLoss, both are zero, that order is opened without problems, but if I send the same order where I specify a value for Takeprofit and I do not specify the stoploss value (still zero) I get "invalid stops" error and it doesn't open the submitted order.

I don't understand why this behavior happens, is it possible to open an order specifying the takeprofit value only?

Thank you very much in advance
 
leo1M: Hi fulks, I'm starting to learn how to write expert advisors and I have the following question: If I send a new order, where I do not specify either the Takeprofit or the StopLoss, both are zero, that order is opened without problems, but if I send the same order where I specify a value for Takeprofit and I do not specify the stoploss value (still zero) I get "invalid stops" error and it doesn't open the submitted order. I don't understand why this behavior happens, is it possible to open an order specifying the takeprofit value only?

Yes, you can use a take-profit without a stop-loss. However, just as the error states, you are setting it incorrectly. In needs to be valid according to the contract specifications, such as normalised to the tick size, greater than the stops level, and properly adjusted according to the closing price and not the opening price.

The following guidelines for Market products are also valid for any other EA ...

Articles

The checks a trading robot must pass before publication in the Market

MetaQuotes, 2016.08.01 09:30

Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
 
Fernando Carreiro #:

Yes, you can use a take-profit without a stop-loss. However, just as the error states, you are setting it incorrectly. In needs to be valid according to the contract specifications, such as normalised to the tick size, greater than the stops level, and properly adjusted according to the closing price and not the opening price.

The following guidelines for Market products are also valid for any other EA ...

Thank you very much Fernando, I'm going to read it immediately!!
Reason: