Thread: How to code?
View Single Post
  #920 (permalink)  
Old 05-15-2008, 01:23 AM
FerruFx FerruFx is offline
Senior Member
 
Join Date: Feb 2007
Posts: 849
FerruFx is on a distinguished road
Quote:
Originally Posted by clarc View Post
i have an EA wich open and mange the position, but sometimes give the indikator the same signal multiple and the EA open everytime this signal comes out an new position - but i dont want a second or third and so on and on position, i will only the first one - is it possible that the EA checks the open position by the basis of the magic number and pair to avoid such multiple entrys ?
Here's the idea:

Quote:
int CountLongs()
{
int count=0;
int trade;
int trades=OrdersTotal();
for(trade=0;trade<trades;trade++) {
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber() != MagicNumber) continue;
if(OrderType()==OP_BUY) count++;
} //---- for
return(count);
}

int CountShorts()
{
int count=0;
int trade;
int trades=OrdersTotal();
for(trade=0;trade<trades;trade++) {
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber() != MagicNumber) continue;
if(OrderType()==OP_SELL) count++;
} //---- for
return(count);
}
And in the start() function:

Quote:
if(CountLongs() == 0 && CountShorts() == 0) {

Your entry condition here
}
Hope that helps.

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Reply With Quote