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

Sell products via the Market and track your sales statistics
839
2015.04.13 10:23

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!

23915
2015.04.13 10:33

hi buddy how are you

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

839
2015.04.13 10:39
goverkms:

hi buddy how are you

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

hey there!

big thanks!

23915
2015.04.13 10:45
you are welcome
839
2015.04.13 11:09
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;
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;
close=CloseOrders();

Sleep(3000);
accountbalance=AccountBalance();
MagicNumber=MagicNumber+1;
}}}}
}```
23915
2015.04.13 11:34
you want to use both conditions?
839
2015.04.13 11:38
goverkms:
you want to use both conditions?
trying to, yes.
23915
2015.04.13 14:06
sorry too busy today remind me tomorrow please if i forget about it
23915
2015.04.14 05:30

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?