Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

OnTester Commission Calculator - MetaTrader 5 Expert | MT5 EA Download - MetaTrader 5 Resources

author EAcpu | 3 reads | 0 comments |

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

Update: Now it also calculates commission for "End of Test" results on the tester

OnTester Commission Calculator - expert for MetaTrader 5

I am testing my Expert Advisor and at the same time I found that I also have to calculate the commission charged by the broker, otherwise the profits shown by the strategy may not be real, so I tried to use the built-in commission function on Metatrader5, but this does not work!

https://www.mql5.com/en/forum/372056

So I decided to code this functionality externally.

This code can be used in your own Expert Advisor to calculate commissions (you may need to know programming)

The EA is suitable for testing Market, Limit, Stop Limit and Stop Market orders and can be selected from the SelectMode input

A percentage fee can be added. Like my broker charges 0.04% commission so I added there

After adding entry, stop loss and take profit you can run this EA on the strategy tester

OnTester Commission Calculator - expert for MetaTrader 5

OnTester Commission Calculator - expert for MetaTrader 5

In the test you can see that I executed a total of 4 trades

OnTester Commission Calculator - expert for MetaTrader 5

For each transaction, the commission should be calculated based on the input: 0.04%

Let's test it on excel

OnTester Commission Calculator - expert for MetaTrader 5

As you can see, for a quantity of 0.1, the buy limit order is 1.2546 and the take profit order is 1.284

So summing up 1.2546 + 1.284 = 2.5386

The total number of transactions is 2

So 2.5386 *2 = 5.0772

Therefore, at the end of the "Strategy Test Report" in the "Log" tab, the total commission will be printed

OnTester Commission Calculator - expert for MetaTrader 5

I hope this calculation method will help you test your EA and get more accurate profits when excluding commissions charged by the broker


Attachment download

📎 commission_calculator.mq5 (14.28 KB)

Source: MQL5 #35461

Verification code Refresh