ea thread

In my early days when dealing with those types of logics, I opted to use Integer Variables. Also to make matters worse, I was making a mistake and my bools were not saving their values. Anyways, my suggestion is to try using an integer. Integers are more flexible. Example
if( Count(Op_Buy)>0 ){Integer=20;}else
if( Count(Op_Sell)>0 ){Integer=10;}else
if( Count(Op_Buy)>0 && Count(Op_Sell)>0 ){Integer=What_Ever_You_Want;}
Yeah sure bools are probably more resource friendly, but I find one usually need 2 bools for what 1 integer can do.
i suggest to use int's and compare them with defined variables. This makes the code much more readable
I have started using ints more recently in preference to bools in some situations for one very simple reason . . . an extern int can be used during optimization, extern bools can't.
extern int aInt_01 = 1; // tester limitation : bool realBool; int init(){ realBool = aInt_01 == 1; } // aInt_01 used only here : if (realBool) ..
Don't kludge your code to get around the tester
if buy is true while sell is false,it will be 20 orders. if sell is true while buy is false,it will be 10 orders
the question is when buy and sell all true,ea will only do as sell is true ?
any advice?
start:
if (!ExistOrder(OP_BUY) && buy){}
bool ExistOrder(int type) {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
if (OrderType()==type){
return(True);
} }}} }
return(false);
}
void OpenOrder(int type) {
string lsComm = GetCommentForOrder();
double ldLot = GetSizeLot();
double buyStop = GetStopLossBuy();
double sellStop = GetStopLossSell();
if(RealOrWarning){
int ticket=0;
if(type==OP_BUY)
ticket=OrderSend(Symbol(),OP_BUY,ldLot,NormalizeDouble(Ask,Digits),Slippage,NormalizeDouble(buyStop,Digits),0,lsComm,MAGIC,0,clOpenBuy);
if(type==OP_SELL)
ticket=OrderSend(Symbol(),OP_SELL,ldLot,NormalizeDouble(Bid,Digits),Slippage,NormalizeDouble(sellStop,Digits),0,lsComm,MAGIC,0,clCloseBuy);
}
}else{
PlaySound(BuyFileSound);
}
}