Trying calculate trade result / OrderCalcProfit - page 2

 
Stephan Wöbbeking #:

Thanks for your effort, I have posted the code in the message above.

BTW I checked for OrderCalcProfit threads, but nothing did any help for me. Either it was much to specific for little, little effects I think I am not looking for. It's not about half a percent off expectation, but we are talking about a factor of 100 (!!!) I am missing. Well, quite a few of those threads are to high-level for me, I was simply not able to understand...

One potential issue with your code is that you're calling OrderCalcProfit(), with price parameters, inside of OnInit(). Based on my past experience, prices are not loaded when OnInit() runs.

See the placement of OrderCalcProfit() in the documentation:

Documentation on MQL5: OrderCalcProfit / Trade Functions
Documentation on MQL5: OrderCalcProfit / Trade Functions
  • www.mql5.com
The function calculates the profit for the current account, in the current market conditions, based on the parameters passed. The function is used...