Edit Your Comment
MT4 EA drawdown per day
Feb 02, 2017 at 09:09
Anggota Sejak Jan 25, 2017
12 pos
Lets say I have an EA applied to an H1 chart.
How would I calculate the drawdown for that day?
Eg.
On Tick:
If (Today is a New Day) then
dailyDrawdown is 100.0
thisMorningsWorth = netAssetValue()
Else
dailyDrawdown = netAssetValue() / thisMorningsWorth
End
If (dailyDrawdown < 0.95) then
chillForToday()
Else
MakeThoseTrades()
End
What's the best way to set this sort of thing up?
How would I calculate the drawdown for that day?
Eg.
On Tick:
If (Today is a New Day) then
dailyDrawdown is 100.0
thisMorningsWorth = netAssetValue()
Else
dailyDrawdown = netAssetValue() / thisMorningsWorth
End
If (dailyDrawdown < 0.95) then
chillForToday()
Else
MakeThoseTrades()
End
What's the best way to set this sort of thing up?
Anggota Sejak Nov 21, 2011
1718 pos
Feb 03, 2017 at 07:51
Anggota Sejak Jan 25, 2017
12 pos
Sketching this out, maybe something like:
--------------------
extern int defaultMaxOrders = 1;
extern double dailyLossLimit = 0.95;
extern double dailyProfitLimit = 1.05;
int today;
double dailyEquity;
double dailyProfit;
bool chillMode = false;
void newDay() {
today = TimeDayOfWeek(TimeCurrent());
dailyEquity = AccountEquity();
chillMode = false;
}
void OnInit() {
today = TimeDayOfWeek(TimeCurrent());
dailyProfit = 1.0;
dailyEquity = AccountEquity();
}
void OnTick() {
if (today != TimeDayOfWeek(TimeCurrent())) {
newDay();
} else {
if (AccountEquity() / dailyEquity > dailyProfitLimit || AccountEquity() / dailyEquity < dailyLossLimit) {
chillMode = true;
closeAll();
}
}
if (openOrders(Symbol()) < defaultMaxOrders && chillMode == false) {
if (isNewCandle()) { makeSomeGoodTrades(); }
}
}
--------------------
?
--------------------
extern int defaultMaxOrders = 1;
extern double dailyLossLimit = 0.95;
extern double dailyProfitLimit = 1.05;
int today;
double dailyEquity;
double dailyProfit;
bool chillMode = false;
void newDay() {
today = TimeDayOfWeek(TimeCurrent());
dailyEquity = AccountEquity();
chillMode = false;
}
void OnInit() {
today = TimeDayOfWeek(TimeCurrent());
dailyProfit = 1.0;
dailyEquity = AccountEquity();
}
void OnTick() {
if (today != TimeDayOfWeek(TimeCurrent())) {
newDay();
} else {
if (AccountEquity() / dailyEquity > dailyProfitLimit || AccountEquity() / dailyEquity < dailyLossLimit) {
chillMode = true;
closeAll();
}
}
if (openOrders(Symbol()) < defaultMaxOrders && chillMode == false) {
if (isNewCandle()) { makeSomeGoodTrades(); }
}
}
--------------------
?
Anggota Sejak Nov 21, 2011
1718 pos
*Penggunaan komersial dan spam tidak akan ditolerir, dan dapat mengakibatkan penonaktifkan akun.
Tip: Memposting gamba /url youtube akan secara otomatis menyematkannya di postingan Anda!
Tip: Ketik tanda @ untuk melengkapi secara otomatis nama pengguna yang ikut serta dalam diskusi ini.