Why does this code does not work?

 

I'm trying to calculate the account balance percentage but this code does not help. Any advice?

I want to use account profit to close all orders when profit  of all open orders exceeds 30 percent. All close code is correct but does seem to work is the code below right?

 
 double ACQ= AccountEquity();

 double ACB=AccountBalance();
 double PRF= ACQ-ACB;// profit
 double PRF1=PRF/ACB;//percent profit
 bool POSP = PRF1>0.30;//If profit is greter than 30 percent
 bool NEP= PRF1<-0.15;// if profit is than negative 15


 

"Doesn't work"...how are you expecting someone to help ? 

 
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here and our crystal balls are cracked.
  2. Posted code is without context. We have no idea where it is, or even if it is being called.
  3. Posted code simply sets some variables. We have no idea wether your "close code" is correct or even if it is being called.
  4. Use the debugger or print out your variables, including _LastError and find out why.
 

The code is on tick, within  the on tick i try to recall.. if  POSP is true then Closeallorders.. close all orders counts all orders and closes them if POSP is true. I have no doubt that my closing order function works because I've used it before. If anyone knows a better way... will appreciate.

Reason: