Thread: How to code?
View Single Post
  #70 (permalink)  
Old 04-24-2006, 05:22 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Quote:
Originally Posted by fxdk
Is there a method in mql4 for checking whether the last trade resulted in profit or loss, after it's closed?

I'm trying OrderSelect() and OrderProfit() with the HistoryTotal() using an array.. but the OrderProfit seems to be referring to the 'open order' , so it's not giving me the results im wanting.

On average, my system has 5 consecutive wins, to 1 lose. What im wanting to do is, after a losing trade, i want to increase the number of lots used as the chances are the next trade after it will be a win.

I therefore need to check what the last closed trade resulted in, before modifying the number of lots.

Any help would be appreciated...
fxdk,

to check the profit of the last closed order use this code:

int total = HistoryTotal();
OrderSelect(total-1,SELECT_BY_POS,MODE_HISTORY);
Alert(OrderProfit()); //This is the last closed order profit or loss
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Reply With Quote