You can combine these two conditon together, like:
int start() {
if (AccountEquity() >= EquityTarget||AccountEquity() <= EquityLoss)
for (int l_ord_total_0 = OrdersTotal(); l_ord_total_0 >= 0; l_ord_total_0--) {
OrderSelect(l_ord_total_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE);
if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket());
}
}
return (0);
}
in your strategy, the balance is either 35000 (may more) or 20000(or less) and stop there. so what is next ? that is just gambling.
You can combine these two conditon together, like:
int start() {
if (AccountEquity() >= EquityTarget||AccountEquity() <= EquityLoss)
for (int l_ord_total_0 = OrdersTotal(); l_ord_total_0 >= 0; l_ord_total_0--) {
OrderSelect(l_ord_total_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE);
if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket());
}
}
return (0);
}
in your strategy, the balance is either 35000 (may more) or 20000(or less) and stop there. so what is next ? that is just gambling.
Hello, when i put your code the EA dont Job, why ?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have any question about one Ea Martingale..
i want limit my Profit and Losses too..
See my idea.
bool UseEquityTarget=false;
extern int EquityTarget=35000;
bool UseEquityLoss=false;
extern int EquityLoss=20000;
int start() {
if AccountEquity() >= EquityTarget
for (int l_ord_total_0 = OrdersTotal(); l_ord_total_0 >= 0; l_ord_total_0--) {
OrderSelect(l_ord_total_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE);
if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket());
}
}
if AccountEquity() >= EquityLoss
for (int l_ord_total_0 = OrdersTotal(); l_ord_total_0 >= 0; l_ord_total_0--) {
OrderSelect(l_ord_total_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE);
if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket());
}
}
return (0);
is correct ?