reversing a code to do a function in an opposite direction.

 

hi there, guys!

i have this little piece of code here that does the following - records your balance, and once equity reaches a specific percent growth over that mark, it closes all trades.

could some one maybe edit it just a bit so it would do the same, but in the opposite direction?

if equity falls a specific percent below the recorded balance, it closes all trades? 

all i can do, is tell it to close the trades once equity is below the recorded balance, so it closes all trades right away..


if(AccountEquity()>=(accountbalance/100*FLUSH_Percent)+accountbalance){



big thanks to any support!

 

hi buddy how are you

if(AccountEquity()<=(accountbalance - accountbalance/100*FLUSH_Percent)){

 
goverkms:

hi buddy how are you

if(AccountEquity()<=(accountbalance - accountbalance/100*FLUSH_Percent)){

hey there!


big thanks!

 
you are welcome
 
goverkms:
you are welcome

big thanks again, it works like a charm!

i dont, however.

thing is - now i tried to make it separate from the first code, but it ignores it.



//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  
  if(time+FLUSH_Time_Seconds<TimeCurrent()){
  time=TimeCurrent();
    
  if(FLUSH){
if(AccountEquity()>=(accountbalance/100*FLUSH_Percent)+accountbalance){
  Sleep((SleepXMinutes*60)*1000);
     first=true;
   nAll=nBuy=nSell=0;
   LastBuy=LastSell=0.0;
  close=CloseOrders();

Sleep(3000);
  accountbalance=AccountBalance();
  MagicNumber=MagicNumber+1;
  }}
  }
  
 
  {{
  
  if(time+FLUSH_Time_Seconds<TimeCurrent()){
  time=TimeCurrent();
    
  if(REBOO){
  if(AccountEquity()<=(accountbalance - accountbalance/100*REBOO_Percent)){
  Sleep((SleepXMinutes*60)*1000);
     first=true;
   nAll=nBuy=nSell=0;
   LastBuy=LastSell=0.0;
  close=CloseOrders();

Sleep(3000);
  accountbalance=AccountBalance();
  MagicNumber=MagicNumber+1;
  }}}}
  }
 
you want to use both conditions?
 
goverkms:
you want to use both conditions?
trying to, yes.
 
sorry too busy today remind me tomorrow please if i forget about it
 

i'll see only one error here if(AccountEquity()>=((accountbalance/100*FLUSH_Percent)+accountbalance))

can you tell me more whats going wrong

none of the conditions is not met?

Reason: