I'm trying to filter the trades with the history, so a buy follows a sell, and it works good.
But, in the morning when there is no trades, i don't know how to say there's no trades (so the expert could fire a buy or a sell), and i need filtering by magic number.
Here is the code i use to find if the previous trade was a buy or a sell (it's working) :
Code: Select all
bool Isprevioustradelong ()
{
if (OrdersHistoryTotal() == 0) return(false);
for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
{
if (!OrderSelect(cc, SELECT_BY_POS, MODE_HISTORY) ) continue;
if (OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() != Symbol() ) continue;
if (OrderType() == OP_BUY) return(true);
//Got this far, so the order was a buy
return(false);
}// bool Isprevioustradelong ()
}//for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
bool Isprevioustradeshort ()
{
if (OrdersHistoryTotal() == 0) return(false);
for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
{
if (!OrderSelect(cc, SELECT_BY_POS, MODE_HISTORY) ) continue;
if (OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() != Symbol() ) continue;
if (OrderType() == OP_SELL) return(true);
//Got this far, so the order was a sell
return(false);
}// bool Isprevioustradeshort ()
}// for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
Code: Select all
bool Isthehistoryclear()
{
for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
{
if (!OrderSelect(cc, SELECT_BY_POS, MODE_HISTORY) ) continue;
if (OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() != Symbol() ) continue;
if (OrdersTotal() == 0 I'M LOST HERE PLEASE HELP ) return (true);
//Got this far, so the history is clear
return(false);
}// bool Isthehistoryclear ()
}//for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)