I have an mql4 function that retrieves the last historical order and then the profit of that last order.... I can't figure out how to do that in mql5.
In mql5, I can retrieve historical data on Orders and Deals. Orders are useless -- to the extent I can determine -- and it appears that any one order can generate multiple deals. I can't retrieve historical positions, there is no api call that I can determine. So, do I retrieve the most recent historical deal, pull the position id from it, gather all other historical deals, then sum all of their profits? If so, please shoot me in the head b/c that's ridiculous
I have an mql4 function that retrieves the last historical order and then the profit of that last order.... I can't figure out how to do that in mql5.
In mql5, I can retrieve historical data on Orders and Deals. Orders are useless -- to the extent I can determine -- and it appears that any one order can generate multiple deals. I can't retrieve historical positions, there is no api call that I can determine. So, do I retrieve the most recent historical deal, pull the position id from it, gather all other historical deals, then sum all of their profits? If so, please shoot me in the head b/c that's ridiculous
raptor, yep, looked at that, but OrderCalcProfit() requires a price_close, which I guess I could use Ask/Bid, based on Buy or Sell so it gets me a little closer to the mql4 functionality b/c it approximates the profit of my actual position. I was hoping to simply recover the mql4 functionality that i use.
any one Order can produce more than one Deal, so looking at just one Deal may not give me an accurate picture, if the multiple deals got farmed out to more than one market transaction partner. Hence, my first supposition that I'd have to first identify the Position from the Position Id of the Order, then collect the Deals and aggregate the profits from the Deals, which is a PITA
- www.mql5.com
If it's for forex, I doubt you ever see more than 1 deal for 1 order. Anyway even in this case, what'is so hard to made a loop and add up profit from the deals, you can use HistorySelectByPosition for that purpose.
this is severely tardy response but, yes, I've already coded up the deal looping but that is pretty inefficient. Also, I don't think making an assumption that one Order produces one Deal, that's just risky. My EA is for Forex only. I feel like I'm missing an important aspect of this new API b/c I'm finding that all of my code ignores Positions altogether
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have an mql4 function that retrieves the last historical order and then the profit of that last order.... I can't figure out how to do that in mql5.
In mql5, I can retrieve historical data on Orders and Deals. Orders are useless -- to the extent I can determine -- and it appears that any one order can generate multiple deals. I can't retrieve historical positions, there is no api call that I can determine. So, do I retrieve the most recent historical deal, pull the position id from it, gather all other historical deals, then sum all of their profits? If so, please shoot me in the head b/c that's ridiculous