Thread: How to code?
View Single Post
  #869 (permalink)  
Old 05-04-2008, 09:59 AM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 519
Michel is on a distinguished road
Quote:
Originally Posted by ak97052d View Post
hello
how to code this:
I need to extract some info from last closed trade,
and after use some info from this last trade
ex:
if last trade profit >0 'lasttradeprofit = 1'

and if last trade <=0 'lasttradeprofit = 0'

lasttradeprofit = 1 // if last trade >0
lasttradeprofit = 0 // if last trade <=0

thanks
It's easy to scan the history and check OrderCloseTime() :
PHP Code:
datetime LastCloseTime;
bool LastTradeIsProfit;
for(
int i 0OrderHistoryTotal(), ++)
{
   
OrderSelect(iSELECT_BY_POSMODE_HISTORY);
   if(
OrderMagicNumber() != Magic) continue;
   if(
OrderCloseTime() > LastCloseTime
   {
      
LastCloseTime OrderCloseTime();
      
LastTradeIsProfit  = (OrderProfit() > 0);
   } 

Reply With Quote