
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
First I will thanks all persons who help me to resolve every question that I have added in this forum.
Like I begin in programmation I have used the following code to limit my number of loss by day (normally EA stops when it looses and it restarts the next day).
I am looking for another simple code to do the same thing. Have you ideas ?
Thanks.
The first code :
int start() {
Message(NumberOfLossPosToday());
}
//+----------------------------------------------------------------------------+
//| Àâòîð : Êèì Èãîðü Â. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Âåðñèÿ : 19.02.2008 |
//| Îïèñàíèå : Âîçâðàùàåò êîëè÷åñòâî óáûòî÷íûõ ïîçèöèé, çàêðûòûõ ñåãîäíÿ. |
//+----------------------------------------------------------------------------+
//| Parametres: |
//| sy - Symbol ("" - any Symbol |
//| NULL - current Symbol) |
//| op - operation (-1 - any position) |
//| mn - MagicNumber (-1 - any magic) |
//+----------------------------------------------------------------------------+
int NumberOfLossPosToday(string sy="", int op=-1, int mn=-1) {
datetime t;
int i, k=OrdersHistoryTotal(), kp=0;
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
t=OrderCloseTime();
if (Year()==TimeYear(t) && DayOfYear()==TimeDayOfYear(t)) {
if (OrderProfit()<0) kp++;
}
}
}
}
}
}
}
return(0);
}
void Message(string m) {
Comment(m);
if (StringLen(m)>0) Print(m);
}