Download MetaTrader 5

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

To add comments, please log in or register
Sell products via the Market and track your sales statistics
Nauris Mucenieks
839
Nauris Mucenieks 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!

Aleksei Beliakov
23915
Aleksei Beliakov 2015.04.13 10:33  

hi buddy how are you

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

Nauris Mucenieks
839
Nauris Mucenieks 2015.04.13 10:39  
goverkms:

hi buddy how are you

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

hey there!


big thanks!

Aleksei Beliakov
23915
Aleksei Beliakov 2015.04.13 10:45  
you are welcome
Nauris Mucenieks
839
Nauris Mucenieks 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;
   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;
  }}}}
  }
Aleksei Beliakov
23915
Aleksei Beliakov 2015.04.13 11:34  
you want to use both conditions?
Nauris Mucenieks
839
Nauris Mucenieks 2015.04.13 11:38  
goverkms:
you want to use both conditions?
trying to, yes.
Aleksei Beliakov
23915
Aleksei Beliakov 2015.04.13 14:06  
sorry too busy today remind me tomorrow please if i forget about it
Aleksei Beliakov
23915
Aleksei Beliakov 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?

To add comments, please log in or register