whats wrong about my code

 

i want when value of Aval chenge with value of Sod . else value of Aval don't back to first value.

please help

thanks

double Aval = 0;
   double Dif ;
   double Sod = (AccountEquity()/Goal) ;
   
   if(Sod >= Aval)
    {
      Aval = Sod ;
    }
   else (Dif = Aval - Sod);
 
looks like Aval will be resetet to 0 every time you run in the method.
 
McBigMoney:
looks like Aval will be resetet to 0 every time you run in the method.
I want code

 
What you're asking for doesn't make sense.
Can you rephrase it?

As it is hard to determine if you are struggling with a logic error or syntactical error.
double available; //zero is the default
double difference;
double sod;

if (AccountEquity()!=0)
{
	sod = AccountEquity()/Goal;
}
else
{
	//deal with it...
}


if (sod >= available) 
{
        available = sod;
}
else 
{
        difference = available - sod;
}
 
focusedbit:
What you're asking for doesn't make sense.
Can you rephrase it?

As it is hard to determine if you are struggling with a logic error or syntactical error.
thanks for comment my problem solved
 
double available; //zero is the default
Zero is not the default. There is no default.
  1. There is no default in MT5
    If a variable is not initialized explicitly, the value stored in this variable can be any. Implicit initialization is not used.
              Language Basics / Variables / Initialization of Variables - Reference on algorithmic/automated trading language for MetaTrader 5
  2. There is no default in MT4 when you use strict (which you should always use.)
Reason: