how to get daily profit of the day using AccountEquity()

 

hello, is this code right? I'm trying to use percentage on my Profit so when the AccountEquity() >= DailyProfitTarget it will close all of the trades I'm not sure on how to code the DailyProfitTarget tnx for the help

void OnTick()   

          double DailyProfitTarget=AccountEquity()+InpDailyProfitInPercentage;
		
		if(AccountEquity>=DailyProfitTarget)
                CloseAllTrades();
 
Karl Robeck:

hello, is this code right? I'm trying to use percentage on my Profit so when the AccountEquity() >= DailyProfitTarget it will close all of the trades I'm not sure on how to code the DailyProfitTarget tnx for the help

 double DailyProfitTarget=AccountEquity()+InpDailyProfitInPercentage;
		
		if(AccountEquity>=DailyProfitTarget)
                CloseAllTrades();

No, think about it. If your equity is 1000 and daily profit is 100, your target is 1,100

How will 1000 ever be larger than 1,100 ?

 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford #:

No, think about it. If your equity is 1000 and daily profit is 100, your target is 1,100

How will 1000 ever be larger than 1,100 ?

My daily profit is on percentage if account equity gain %target percentage it will close all trades
 
Keith Watford #:
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Oh sorry about that i did not see the section when i post this topic and thanks for moving it 
 
Karl Robeck #:
My daily profit is on percentage if account equity gain %target percentage it will close all trades

As I said, think about it

double DailyProfitTarget=AccountEquity()+InpDailyProfitInPercentage;
		
		if(AccountEquity>=DailyProfitTarget)
                CloseAllTrades();
double DailyProfitTarget= X + Y;
		
		if(X>=X+Y)
                CloseAllTrades();
 
Karl Robeck:

hello, is this code right? I'm trying to use percentage on my Profit so when the AccountEquity() >= DailyProfitTarget it will close all of the trades I'm not sure on how to code the DailyProfitTarget tnx for the help

Yes is correct… you put 2 paranteses on AccountEquity() and is good…. It won’t do anything but is good… 
Reason: