Quote:
Originally Posted by ak97052d
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 = 0; i > OrderHistoryTotal(), i ++)
{
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if(OrderMagicNumber() != Magic) continue;
if(OrderCloseTime() > LastCloseTime)
{
LastCloseTime = OrderCloseTime();
LastTradeIsProfit = (OrderProfit() > 0);
}
}