I am running on historical data, the variables macd1,2, lowprice, highprice are assigned values, but the condition does not want to run, I broke my head can not understand where to dig ... (((
Total mess and no understanding of what you are doing
bool takelimit; // Здесь переменная равна false//--- Здесь вот что: сначала выбирается ордер по тикету (MODE_TRADES здесь не нужно от слова "совсем", что говорит о том, что вы не представляете что вы делаете), //--- далее переменной takelimit присваивается результат работы функции выбора ордера, //--- и если ордер есть с таким тикетом, или был когда-то, то функция вернёт true, и takelimit будет присвоено true, соответственно, будет выведен код последней ошибки,//--- что вовсе не говорит, что ошибка здесь была при выборе ордера по тикету - вы же переменную, хранящую код последней ошибки, не сбросили при помощи ResetLastError()//--- И далее вообще не понятно к чему у вас фигурные скобки - они висят в пустоте, а это составной оператор, который должен после условия идти.if(takelimit=OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print(string(takelimit)+" :",GetLastError());//здесь возвращает число 11, получается ошибка код 11, но не нашел расшифровку нигде?
{
if(iBarShift(Symbol(),0,OrderOpenTime())==1)
deletelimit=OrderDelete(ticket);
if(!deletelimit)
Comment(GetLastError());
}
//+------------------------------------------------------------------+//--- А нужно примерно так (фигурные скобки специально оставил для понимания где какой блок кода):ResetLastError();
if(OrderSelect(ticket,SELECT_BY_TICKET) && OrderCloseTime()==0)
{
if(iBarShift(Symbol(),PERIOD_CURRENT,OrderOpenTime())==1)
{
if(!OrderDelete(ticket))
Print("Ошибка удаления ордера #",(string)ticket,": ",GetLastError());
}
}
else
{
Print("Ошибка выбора ордера #",(string)ticket,": ",GetLastError());
}
Print(takelimit,GetLastError()) returns two values because the 1st variable is of bool type and does not need GetLastError, and since there is a comma, GetLastError returns the last error in the code at the time of calling GetLastError?
Yeah... there's two values that print.....
That's almost exactly what you wrote.
int ticket;
void Fn()
{
ResetLastError();//Сбрасываем код предыдущей ошибкиif(!OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)){Print(GetLastError());}//Если не выбран ордер по указанному тикету-принтим код ошибкиelse//иначе(если ордер нашёлся)
{
if(iBarShift(Symbol(),0,OrderOpenTime())==1 && !OrderDelete(ticket)){Comment(GetLastError());}//Если выбранный ордер открылся на предыдущем баре и не удалось его удалить(надеюсь Вы работаете с отложенниками)-тогда выводим комент ошибки
}
}
Ah... so you're responding to the wrong person... I see)
Yes, I was replying to the same person you were replying to. But you also told him the wrong thing - read when MODE_TRADES is required and when it is not. And how an order should be selected on a ticket.
Well, yes, I was answering the same person you were answering. But you also have not told him everything correctly - read when MODE_TRADES is required and when it is not. And how to select an order by ticket.
MODE_TRADES hasn't looked at it yet, just the piece that 11 printed...
Hi all!
I spent half the night trying to figure out why a simple condition does not work, please help me figure it out:
I am running on historical data, the variables macd1,2, lowprice, highprice are assigned values, but the condition does not want to run, I broke my head can not understand where to dig ... (((
maybe 1 and 1 ?/i.e. true and error code 1
Total mess and no understanding of what you are doing
Print(takelimit,GetLastError()) returns two values because the 1st variable is of bool type and does not need GetLastError, and since there is a comma, GetLastError returns the last error in the code at the time of calling GetLastError?
Yeah... there's two values that print.....
That's almost exactly what you wrote.
Yes... there are two values to print.....
That's almost exactly what you wrote.
A complete mess and a misunderstanding of what you're doing...
I'm not actually doing anything, I just assumed that the man will print 1 and 1 instead of 11))
and that's all...
A complete mess and misunderstanding of what you're doing...
Ah... so you're responding to the wrong person... I see)
I'm not actually doing anything, I just assumed that the person will print not 11, but 1 and 1.)
Like this line here:
Should I print "11"?
It'll print "1:1" then.
The error code 1 is no error, but the result is unknown.
Like this line here:
Can it print "11"?
It'll print "1:1" then.
The error code 1 is no error, but the result is unknown.
Yes, I've already changed it!
Ah... so you're responding to the wrong person... I see)
Yes, I was replying to the same person you were replying to. But you also told him the wrong thing - read when MODE_TRADES is required and when it is not. And how an order should be selected on a ticket.
Well, yes, I was answering the same person you were answering. But you also have not told him everything correctly - read when MODE_TRADES is required and when it is not. And how to select an order by ticket.
MODE_TRADES hasn't looked at it yet, just the piece that 11 printed...