Discussion of article "Library for easy and quick development of MetaTrader programs (part XXIII): Base trading class - verification of valid parameters"

 

New article Library for easy and quick development of MetaTrader programs (part XXIII): Base trading class - verification of valid parameters has been published:

In the article, we continue the development of the trading class by implementing the control over incorrect trading order parameter values and voicing trading events.

Compile the EA and launch it in the tester, while preliminarily setting Lots to 10, as well as StopLoss in points and TakeProfit in points to 1 point each in the parameters:


Thus, we attempt to open a position with an invalid lot size, so that the funds for opening it are insufficient, and try violating the minimum stop order distance regulated by symbol's StopLevel parameter:


The EA displays two errors in the journal — "Not enough money to perform trading operation" and "StopLoss values violate the StopLevel parameter requirements". We have also set TakeProfit to one point. Why does the EA display no info of that error as well? Actually, there is no error here since placing TakeProfit and StopLoss levels performed within the minimum SYMBOL_TRADE_STOPS_LEVEL does not violate the rule:

TakeProfit and StopLoss levels should be compared to the current price for performing the opposite operation

  • Buying is done at the Ask price — the TakeProfit and StopLoss levels should be compared to the Bid price.
  • Selling is done at the Bid price — the TakeProfit and StopLoss levels should be compared to the Ask price.

Author: Artyom Trishkin

 

Hi, what is the recommended way to get the price levels (entry, SL, TP) checked and, optionally corrected, by the library before submitting a pending order or opening a position? The first time I read through your article series, I had the impression that this was possible via CEngine interface but now can't find how (or misunderstood the first time). The only methods I see are in Ctrading and are not public either -- CTrading::CheckLevels(), CTrading::RequestErrorsCorrecting(), etc...

 
Dima Diall:

Hi, what is the recommended way to get the price levels (entry, SL, TP) checked and, optionally corrected, by the library before submitting a pending order or opening a position? The first time I read through your article series, I had the impression that this was possible via CEngine interface but now can't find how (or misunderstood the first time). The only methods I see are in Ctrading and are not public either -- CTrading::CheckLevels(), CTrading::RequestErrorsCorrecting(), etc...

Hi Artyom - can you clarify this for me, please?
 
Dima Diall :
Hi Artyom - can you clarify this for me, please?

Please, a little later - very busy for now.

Reason: