Boolean Question

Cristian Baciu
599
Hello, I have a question if I have something like this:
if (condition)
{
Bool x=true;
 for (int i = (total-1); i >= 0; i --)
         {if ( OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
             if(OrderType() == OP_BUY &&  OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
             if (condition1)
continue;
  else
    x=false;}
 if (x)
 {
 Bool y=true;
 for (int k = (total-1); k >= 0; k --) 
         {if ( OrderSelect(k, SELECT_BY_POS, MODE_TRADES)) 
             if(OrderType() == OP_BUY &&  OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
             if (condition2)
break;
 else
   y=false;}

 if (y)
{ open order condition
}
}
}
I have to mention that, if I put each Bool individually in program works perfect... but when I try to combine them it's going wrong. Hope you will understand what I am trying
William Roeder
25824
William Roeder  

No idea what you're trying to do.

Your code says: If I find an open order (belonging to me) that doesn't match condition1 and I find a (possibly different) order (also belonging to me) that doesn't match condition2 then (and only then) do I "open order condition"

Cristian Baciu
599
Cristian Baciu  
My both condition are compare prices. And if 1st condition is real than also the 2nd condition must be true and only after both of them are true to open order. And if I write a program with only 1st condition it is working smooth, same with 2nd condition... I don`t know how to combine them... Because now when both of them are in the same program only one of them is working.
Cristian Baciu
599
Cristian Baciu  
So still someone that can help me fix this code? Or who can lead me on other way of thinking in fixing this...
Simon Gniadkowski
17410
darchii:
So still someone that can help me fix this code? Or who can lead me on other way of thinking in fixing this...

As far as I am concerned you haven't explained clearly what your issue is.  Why can't you simply code . . .

if( condition1 && condition2 )
   {
   // do something
   }
Cristian Baciu
599
Cristian Baciu  

As I said previously, my both conditions need a select order loop, and if I put them in the same loop I do not get the result I need it ... because my X conditions is searching for double position at the same price (so I need an order select in a bool) and my Y condition is a way to open order from step to step... If I put every block just as a single block works perfectly, but I need both of them to work together in the same EA.


PS: And this is the only way I thought it will works... maybe there is another way with void but I do not understand how to use void function and couldn`t find a tutorial or book to explain it well.

Ian Venner
2400
Ian Venner  

Why do you think people should help you if you cant be bothered to write a clear and accurate description of what you are trying to do? That vague 2 line post won't cut it.

I am takig a wild guess from what you said,  are you saying you want to condition1 to be filled more than once before proceeding to test for condition2 ?