# Orderhistory Matching howto

636

```/**
Scan History
**/

bool InHistory(double magic)
{
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if(OrderMagicNumber() == magic) {
return(TRUE);
break;
}
else {
return(FALSE);
}

}
}
```

This function of mine does not seem to work, I need help with this.

I want to match with magicnumber and see if same order has opened before

5390

bonechair:

This function of mine does not seem to work, I need help with this.

I want to match with magicnumber and see if same order has opened before

```/**
Scan History
**/

bool InHistory(double magic) <-Magic should be integer not double
{
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);<-Put this within an if() statement
if(OrderMagicNumber() == magic) {
return(TRUE);
break;<-The break is useless because it'll return above.
}
else {<-One way or the other, its going to return true or false on the first check.
return(FALSE);<-Therefore if the 1st in history doesn't match the magic it returns false
}

}
} ```
Moderator
8293

```/**
Scan History
**/

bool InHistory(double magic)
{
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if(OrderMagicNumber() == magic) {
return(TRUE);
}
}