kolyango: How do I make this code check whether we already have a buy order or not before buying. If there are no market buy orders, then only then execute the buy?
I have posted an EA today in my toys. It's all there.
How do I make this code check whether we already have a buy order or not before buying. If there are no market buy orders, then only then execute the buy?
extern double LOT = 0.01; //-------------------------------------------------------------------------------------------- int start() { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) { if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue; OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White); Alert (GetLastError()); // Выводит сообщение об ошибке
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green); Alert (GetLastError()); // Выводит сообщение об ошибке return(0); } } } //--------------------------------------------------------------------------------------------
How do I make this code check whether we already have a buy order or not before buying. If there are no market buy orders, then only then execute the buy?
extern double LOT = 0.01; //-------------------------------------------------------------------------------------------- int start() { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) { if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue; OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White); Alert (GetLastError()); // Выводит сообщение об ошибке
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green); Alert (GetLastError()); // Выводит сообщение об ошибке return(0); } } } //--------------------------------------------------------------------------------------------
How do I make this code check whether we already have a buy order or not before buying. If there are no market buy orders, then only then execute the buy?
I have posted an EA today in my toys. It's all there.
I posted an advisor in toys today. It's all there.
What kind of toys?
What kind of toys?
https://www.mql5.com/ru/forum/108553/page28
https://www.mql5.com/ru/forum/108553/page28
Which one is it? The name of it...
Which one is it? The name of it...
There's only one advisor of mine. Doesn't seem to help, though.
There's only one advisor of mine. Although from the looks of it, it won't help.
))))))
How do I make this code check whether we already have a buy order or not before buying. If there are no market buy orders, then only then execute the buy?
extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
}
//--------------------------------------------------------------------------------------------
How do I make this code check whether we already have a buy order or not before buying. If there are no market buy orders, then only then execute the buy?
extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
}
//--------------------------------------------------------------------------------------------
int OrderBuy=0;
for(int cnt=0;cnt<OrdersTotal();cnt++){
if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)){
if(OrderMagicNumber()==Magic){
if(OrderSymbol()==Symbol()){
if(OrderType()==OP_BUY) OrderBuy++;
} } } }
if(OrderBuy==0) Open a position.
int OrderBuy=0;
for(int cnt=0;cnt<OrdersTotal();cnt++){
if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)){
if(OrderMagicNumber()==Magic){
if(OrderSymbol()==Symbol()){
if(OrderType()==OP_BUY)OrderBuy++;
} } } }
if(OrderBuy==0) Open position.
int i;
extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
//-----
for (i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
int OrderBuy=0;
for(int cnt=0;cnt<OrdersTotal();cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
{
if(OrderMagicNumber()==Magic)
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) OrderBuy++;
}
}
}
}
if(OrderBuy==0) // Открыть позицию
{
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
}
//-----
}
//--------------------------------------------------------------------------------------------
'Magic' - variable not defined C:\Program Files (x86)\Alpari ÌÒ4\experts\111.mq4 (25, 36)
How do you define Magic ? int Magic? And there's probably no need to assign anything, right?