You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
After language changes over the last year, my version of Virtual stopped working. I switched back to yours.
But I really missed a commission that would take into account price changes. Especially for crypto, where the price changes many times during testing.
In my old version was accurate, but slow calculation with string operations and querying prices by instrument. Probably from this slowdown you didn't want to add it to your own.
This time I made a simple and fast calculation for instruments like EURUSD, AUDUSD ... with USD deposit currency and for all crypto, there all to USDT. I.e. if quote currency == account currency, the calculation will be correct.
#define COMMISSION_TO_PRICE 2 // умножить полученную комиссию на цену, например для EURUSD *=1.12345; 1 - комиссия берется только при входе, 2 - комиссия берется 2 раза и при входе и при выходе
The commission is simply multiplied by OpenPrice or ClosePrice. For instruments like USDJPY or if the deposit currency is not USD(T), the option can be disabled, as it will not be accurate (like your current option).
Here is what I got on EURUSD:
As you can see, with the added option the commission differs only by 18 cents for 140 trades. And without it by 42 dollars. Of course, you can select in your variant the average multiplier not 4, but 4.305 for example (average commission for the test), but it will have to be done manually for each instrument and recompile.
The edits are not big, I hope you will want to add this option to the library code. Or maybe you will think of something more universal.
In fact, this formula always works.
Of course, you can choose in your variant the average multiplier not 4, but 4.305 for example (average commission for the test), but it will have to be done manually for each instrument and recompile.
Another variant.
Edits are not big, I hope you will want to add this variant to the library code. Or maybe you will think of something more universal.
Totally agree that the edit is useful and should be made. It should be checked for partial close (OrderClose not for the whole lot) and CloseBy. To check it, it is enough to write a script where two differently directed positions are opened on the same tick and a partial and CloseBy-close are made at once. I am not ready to do it myself yet. If you provide such a script with correct results, I will make your corrections faster.
In fact, this formula works all the time.
About - there are probably some brokerage centres that take commission only at opening - for them it is better not to take it into account. For pipsing the difference will be small, but for big targets it will be noticeable.
Totally agree that the edit is useful and should be made. It is necessary to check for partial closing (OrderClose not for the whole lot) and CloseBy. To check it, it is enough to write a script where two differently directed positions are opened on the same tick and a partial and CloseBy-close are made at once. I am not ready to do it myself yet. If you send me such a script with a correct result, I will make your corrections faster.
Virtual adds a commission to non-performing limits:

Apparently we need to do a type checkVirtual adds a commission to unexecuted limits:
Apparently we need to do a type checkResult.
It works correctly. Apparently, these edits require additional checking.
It works correctly. Apparently, these edits require additional verification.
You are right.
In ToClose() I added calculation of commissions outside if (this.IsPosition()){
Fixed it, attached the file