so it should check if there are no open positions with this wizard at all, no matter with what time of opening..... a simple limit on the wizard....toast
if(ExistPositions(NULL,-1,44444,-1)==false)//if there are no open positions with this magic number then check......
.... or maybe I do not understand.... I have -1 because I do not care when a position opened ..... anyway it will open only on a new bar and when the old one is closed because the conditions specify that the position can open only if there are no open positions with this magic number
to make it even simpler: open position and wait until it closes.... when it closes then opens again and certainly should not open on every bar a position with such a magician.... it is checked again if there are no open positions with such magician
found the mistake..... it is all about the symbol I was setting that I do not care what symbol to look for as long as it would not be with this magician but when I set that the current one is ok to start....though strange because if it is not on the current symbol and is on another then we would not have to open the deal until it closes on the other symbol with this magician
woin2110: How do I prevent a limit from being set if it's already there?
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 12.03.2008 |//| Описание : Возвращает флаг существования ордеров. |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента ("" - любой символ, |//| NULL - текущий символ) |//| op - операция (-1 - любой ордер) |//| mn - MagicNumber (-1 - любой магик) |//| ot - время открытия ( 0 - любое время установки) |//+----------------------------------------------------------------------------+bool ExistOrders(string sy="", int op=-1, int mn=-1, datetime ot=0) {
int i, k=OrdersTotal(), ty;
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
ty=OrderType();
if (ty>1 && ty<6) {
if ((OrderSymbol()==sy || sy=="") && (op<0 || ty==op)) {
if (mn<0 || OrderMagicNumber()==mn) {
if (ot<=OrderOpenTime()) return(True);
}
}
}
}
}
return(False);
}
so it should check if there are no open positions with this wizard at all, no matter with what time of opening..... a simple limit on the wizard....toast
if(ExistPositions(NULL,-1,44444,-1)==false)//if there are no open positions with this magic number then check......
.... or maybe I do not understand.... I have -1 because I do not care when a position opened ..... anyway it will open only on a new bar and when the old one is closed because the conditions specify that the position can open only if there are no open positions with this magic number
to make it even simpler: open position and wait until it closes.... when it closes then opens again and certainly should not open on every bar a position with such a magician.... it is checked again if there are no open positions with such magician
So put 0 in the last parameter, so that it doesn't matter when the position is opened.
So put 0, in the last parameter, so it won' t matter when the position opened.
I did that and it didn't help, it still generates a position on every bar
if(!ExistPositions(Symbol(),-1,44444))OpenPosition(Symbol(),OP_BUY,0.1,Ask-sl*Point,Ask+tp*Point,44444)
poprobuj
it doesn't work either, still stamping a trade on every bar
it does not help still stamping on every bar
found the mistake..... it is all about the symbol I was setting that I do not care what symbol to look for as long as it would not be with this magician but when I set that the current one is ok to start....though strange because if it is not on the current symbol and is on another then we would not have to open the deal until it closes on the other symbol with this magician
How can I introduce a parameter such as the angle of a moving average with certain parameters into an EA?
It depends on what to prick )))
How do I prevent a limit from being set if it's already there?
How can I prevent a limit from being set if it's already set?