Code IF statement to NOT enter new trades

 

I have this code in my open order section, based on specific criteria. I added an INPUT 

input Bool Exit_Only = False;

where if Exit_Only is TRUE then expert will not enter new trades, only exit and manage. This is if I want to stop the expert without closing all open orders.

What would I add to the existing section? 


void ManageOpen()

  {

   double ind0val1 = iAC(NULL,0,1);

   double ind0val2 = iAC(NULL,0,2);

   bool ind0long  = ind0val1 > Ind0Param0 + sigma && ind0val2 < Ind0Param0 - sigma;

   bool ind0short = ind0val1 < -Ind0Param0 - sigma && ind0val2 > -Ind0Param0 + sigma;



   double ind1val1 = iCCI(NULL,0,Ind1Param0,PRICE_TYPICAL,1);

   double ind1val2 = iCCI(NULL,0,Ind1Param0,PRICE_TYPICAL,2);

   bool ind1long  = ind1val1 > ind1val2 + sigma;

   bool ind1short = ind1val1 < ind1val2 - sigma;



   double ind2val1 = iRVI(NULL,0,Ind2Param0,MODE_MAIN,1);

   bool ind2long  = ind2val1 < Ind2Param1 - sigma;

   bool ind2short = ind2val1 > -Ind2Param1 + sigma;



   const bool canOpenLong  = ind0long && ind1long && ind2long;

   const bool canOpenShort = ind0short && ind1short && ind2short;



   if(canOpenLong && canOpenShort)

      return;



   if(canOpenLong)

      OpenPosition(OP_BUY);

   else if(canOpenShort)

      OpenPosition(OP_SELL);

  }


Thank you for your help.

 
pomer2741: What would I add to the existing section? 
Code that does your "if Exit_Only is TRUE then expert will not enter new trades, only exit and manage"
 
William Roeder:
Code that does your "if Exit_Only is TRUE then expert will not enter new trades, only exit and manage"

Where would I put that among all that code? Seems to have several conditions.

   const bool canOpenLong  = ind0long && ind1long && ind2long;

   const bool canOpenShort = ind0short && ind1short && ind2short;

 
if (! Exit_Only) ManageOpen();

The logical negation (! symbol) is flipping a Boolean's value. It's like saying if (Exit_Only==false), but this isn't considered good coding style so just use the symbol.