It turns out that SymbolSelect("AUDUSD", true) returns true only if AUDUSD is not in MarketWatch - i.e. when the pair is added to MarketWatch. Once the pair is in MarketWatch, subsequent calls return false.
This behavior does not match the manual of this function at all.
Something prompts me that we can do without SymbolSelect().
laveosa: it took me 4 months to make an owl on alpari..... nano quanto code is very fucking time consuming and not small..... and now everything is !!!!! it's a shame .... I have no idea what to do with it.
Third owl and still the same error, glad the problem is not with the code :)
Here's the thing, I put a new "No" (it's a high-speed fibre glass cable with a download speed of 7mb per second.) and after that I got the same thing with Alpari, but with Master Forex everything is OK and Admeral too ......... here is another nuance, the broker is installed on the drive D:) when reinstalling the OS I didn't install a new one and use the old one .... maybe i should install it?
Hello all. I started writing EAs not too long ago. I have faced a seemingly elementary problem, which I cannot solve. Please help.
The problem. On a new tick I lose the value of a variable.
Short description. Assign to some variable the return value of the OrderSend() function and exit using the return command. On the next tick the variable value becomes equal to zero.
The key element of the source code. The full source code below.
if (SAR_Prev>LastClose && SAR_Prev2<LastClose2) { int ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Ask+StopLoss*Point,Bid-TakeProfit*Point,",111,0,Red); Alert ("Assigned value to ticket_sell variable ", ticket_sell); return; } }
Alert ("Exist position = ", position_exists, "Buy order ", ticket_buy, "Sell order ", ticket_sell);
Result.
The screenshot shows that the position was successfully opened and the order ticket was memorized in the ticket_sell variable. However, the ticket_sell variable becomes zero on the next tick. And I cannot modify/delete the order on the ticket.
// Простой параболик. Переворотная стратегия.// В условиях, когда в терминале уже есть открытые позиции по другим инструментам.inputdouble TakeProfit =2500;
inputdouble StopLoss =400;
inputdouble Lots =1;
inputdouble TrailingStop =100;
inputdouble Parameter1 =0.02; // Параметры индикатора PSARinputdouble Parameter2 =0.2;
voidOnTick()
{
int position_exists; // Переменная, принимающая значения 0 или 1. Указывает, открыта ли позиция по интструменту EURUSD// Занесение в переменные значений индикатора на последнем и предпоследнем закрывшихся барах double SAR_Prev=iSAR(NULL,0,Parameter1,Parameter2,1);
double SAR_Prev2=iSAR(NULL,0,Parameter1,Parameter2,2);
// Занесение в переменные цен закрытия на последнем и предпоследнем барахdouble LastClose=iClose(NULL,0,1);
double LastClose2=iClose(NULL,0,2);
//--------------------------------------------------------------------- // Блок, который определяет, открыта ли позиция по инструменту EURUSD// путём перебора всех открытых ордеров терминала в цикле. // Если позиция открыта, то переменной position_exists будет присвоено значение 1int cnt;
string sym;
int type;
int total=OrdersTotal();
position_exists=0;
for (cnt=0; cnt<=total-1; cnt++)
{
bool select=OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
sym=OrderSymbol();
type=OrderType();
if (sym=="EURUSD" && (type==1 || type==0))
{
position_exists=1;
break;
}
}
//--------------------------------------------------------------------- // Если позиция по EURUSD не существует, то проверяем условия открытия сделки if(position_exists==0)
{
if (SAR_Prev<LastClose && SAR_Prev2>LastClose2)
{
int ticket_buy=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Bid-StopLoss*Point,Ask+TakeProfit*Point," ",111,0,Blue);
Alert ("Присвоили значение пременной ticket_buy ", ticket_buy);
return;
}
if (SAR_Prev>LastClose && SAR_Prev2<LastClose2)
{
int ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Ask+StopLoss*Point,Bid-TakeProfit*Point," ",111,0,Red);
Alert ("Присвоили значение пременной ticket_sell ", ticket_sell);
return;
}
}
Alert ("Существование позиции = ", position_exists, " Ордер на покупку ", ticket_buy, " Ордер на продажу ", ticket_sell);
//--------------------------------------------------------------------- // Если позиция по EURUSD существует, то проверяем условия закрытия позиции if (position_exists==1)
{
if (ticket_sell==0) // Если открытой позиции на продажу нет, то выбираем открытый ордер на покупку по тикету
{bool select_buy=OrderSelect(ticket_buy,SELECT_BY_TICKET,MODE_TRADES);}
if (ticket_buy==0) // Если открытой позиции на покупку нет, то выбираем открытый ордер на продажу по тикету
{bool select_sell=OrderSelect(ticket_sell,SELECT_BY_TICKET,MODE_TRADES);}
if(OrderType()==OP_BUY)
{
if(SAR_Prev>LastClose && SAR_Prev2<LastClose2) // Проверяем уловия для закрытия длинной позиции
{
bool close_buy=OrderClose(OrderTicket(),OrderLots(),Bid,0,Violet);
return;
}
}
if(OrderType()==OP_SELL)
{
if(SAR_Prev<LastClose && SAR_Prev2>LastClose2) // Проверяем уловия для закрытия короткой позиции
{
bool close_sell=OrderClose(OrderTicket(),OrderLots(),Ask,0,Violet);
return;
}
}
}
}
Hello all. I started writing EAs not too long ago. I have faced a seemingly elementary problem, which I cannot solve. Please help.
The problem. On a new tick I lose the value of a variable.
Short description. Assign to some variable the return value of the OrderSend() function and exit using the return command. On the next tick the variable value becomes equal to zero.
The key element of the source code. The full source code below.
if (SAR_Prev>LastClose && SAR_Prev2<LastClose2) { int ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Ask+StopLoss*Point,Bid-TakeProfit*Point,",111,0,Red); Alert ("Assigned value to ticket_sell variable ", ticket_sell); return; } }
Alert ("Exist position = ", position_exists, "Buy order ", ticket_buy, "Sell order ", ticket_sell);
Result.
The screenshot shows that the position was successfully opened and the order ticket was memorized in the ticket_sell variable. However, the ticket_sell variable becomes zero on the next tick. And I cannot modify/delete the order on the ticket.
To avoid losing value, we need a global variable, put its declaration outside ofOnTick() or make it static
// Простой параболик. Переворотная стратегия.// В условиях, когда в терминале уже есть открытые позиции по другим инструментам.inputdouble TakeProfit =2500;
inputdouble StopLoss =400;
inputdouble Lots =1;
inputdouble TrailingStop =100;
inputdouble Parameter1 =0.02; // Параметры индикатора PSARinputdouble Parameter2 =0.2;
staticint ticket_sell =0;voidOnTick()
{
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
It turns out that SymbolSelect("AUDUSD", true) returns true only if AUDUSD is not in MarketWatch - i.e. when the pair is added to MarketWatch. Once the pair is in MarketWatch, subsequent calls return false.
This behavior does not match the manual of this function at all.
Something tells me you can do without SymbolSelect().
Yeah, just updated my post above
What's the other one, or should we be doing a leg up on this one already?!
Master Forex
it took me 4 months to make an owl on alpari..... nano quanto code is very fucking time consuming and not small..... and now everything is !!!!! it's a shame .... I have no idea what to do with it.
Third owl and still the same error, glad the problem is not with the code :)
Master Forex
Thanks, I will have a look!
Thanks, I'll have a look!
Not campaigning, just answering a question :)
Hello all. I started writing EAs not too long ago. I have faced a seemingly elementary problem, which I cannot solve. Please help.
The problem. On a new tick I lose the value of a variable.
Short description. Assign to some variable the return value of the OrderSend() function and exit using the return command. On the next tick the variable value becomes equal to zero.
The key element of the source code. The full source code below.
if (SAR_Prev>LastClose && SAR_Prev2<LastClose2)
{
int ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Ask+StopLoss*Point,Bid-TakeProfit*Point,",111,0,Red);
Alert ("Assigned value to ticket_sell variable ", ticket_sell);
return;
}
}
Alert ("Exist position = ", position_exists, "Buy order ", ticket_buy, "Sell order ", ticket_sell);
Result.
The screenshot shows that the position was successfully opened and the order ticket was memorized in the ticket_sell variable. However, the ticket_sell variable becomes zero on the next tick. And I cannot modify/delete the order on the ticket.
Hello all. I started writing EAs not too long ago. I have faced a seemingly elementary problem, which I cannot solve. Please help.
The problem. On a new tick I lose the value of a variable.
Short description. Assign to some variable the return value of the OrderSend() function and exit using the return command. On the next tick the variable value becomes equal to zero.
The key element of the source code. The full source code below.
if (SAR_Prev>LastClose && SAR_Prev2<LastClose2)
{
int ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Ask+StopLoss*Point,Bid-TakeProfit*Point,",111,0,Red);
Alert ("Assigned value to ticket_sell variable ", ticket_sell);
return;
}
}
Alert ("Exist position = ", position_exists, "Buy order ", ticket_buy, "Sell order ", ticket_sell);
Result.
The screenshot shows that the position was successfully opened and the order ticket was memorized in the ticket_sell variable. However, the ticket_sell variable becomes zero on the next tick. And I cannot modify/delete the order on the ticket.
To avoid losing value, we need a global variable, put its declaration outside ofOnTick() or make it static
I.e. it would go something like this: