Hello,
I am adding new feature in my EA, which close trade automatically when it fulfilled defined earning set by user and than it redefine with value again with new Account balance.
Example :
Account Balance = $1000
Target Percentage = 10% (10% of 1000$ = $100)
When Account balance is above $1100, close all the running trade whether it in positive or negative. Than it start again but now the Account balance is $1100 and 10% targeted percentage is $110. and it keep repeating.
To do this, i am trying like :
extern double Target_Percentage = 10;
double target_profits = AccountBalance() * (Target_Percentage * 0.01); //Calculating in Percentage
static double target_Capital = AccountBalance() + target_profits; //Setting the value in static so it will not change on every tick.
if(AccountEquity() >= target_Capital) { //Comparing Account Equity with total targeted revenue i need.
CloseAllTrade();
Print("All the trade has been successfully closed as it reached Targeted Capital requirement and targeted capital redjusted automatically to new value based on new capital");
}
The problem is, i do not know how i can set new value to the static double target_Capital . If it static it value will be remained unchanged but i want to redefine static target_capital to new value ones it fulfilled previous targeted percentage requirement.