1. One thing I see here is you think deal type corresponds to position type. This is not true...
A position consists of two deals: (in deal and out deal).
2. The profit you are looking for is saved in out deal and not in deal.
I just delete the dealType variable and it still return 0
I found that the magic number filter is the culprit. I do print statement before and after magic number filter and it shows after magic number filter the profit always 0. Any clue why this happened?
Just fix the problem. Apparently when using CTrade to close a position, if we don't use SetExpertMagicNumber() function the deal that came out of it will be 0. After add SetExpertMagicNumber() when close position the deal will have the same magic number.
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
I want to calculate a history profit on OnDeInit event handler. This function only runs when backtesting the strategy. My code looks like this,
For some reason it returns 0 for all of the currency. Anyone knows where the problem is?