u can please show the all line for both (OP_BUY & OP_SELL)
//======================= THE BELOW CODE IS FOR LONG ORDERS ===============================================
if (Buy_Signal==true)
{
if (OrdersTotal()==0)
{
OrderSend(Symbol(),OP_BUY,Lot_Size,Bid,Permissible_Slippage,b-P1000,a+P100,NULL,0,0,Blue);
}
if (OrdersTotal()==1)
{
OrderSelect(OrderTicket(), SELECT_BY_POS, MODE_TRADES);
if (OrderType()==OP_SELL)
{
OrderSend(Symbol(),OP_BUY,Lot_Size,Bid,Permissible_Slippage,b-P1000,a+P100,NULL,0,0,Blue);
}
}
}
//======================== THE BELOW CODE IS FOR SHORT ORDERS ==============================================
if (Sell_Signal==true)
{
if (OrdersTotal()==0)
{
OrderSend(Symbol(),OP_SELL,Lot_Size,Ask,3,a+P1000,b-P100,NULL,0,0,Red);
}
}
if (OrdersTotal()==1)
{
OrderSelect(OrderTicket(), SELECT_BY_POS, MODE_TRADES);
if (OrderType()==OP_BUY)
{
OrderSend(Symbol(),OP_SELL,Lot_Size,Ask,3,a+P1000,b-P100,NULL,0,0,Red);
}
}
//================ THE BELOW CODE CLOSES ALL OPEN ORDERS AS A NEW BAR FORMS======================
if (TimeCurrent()==Time[0])
{
int total = OrdersTotal();
for(int j=total-1;j>=0;j--)
{
OrderSelect(j, SELECT_BY_POS);
int type=OrderType();
bool result= false;
switch(type)
{
case OP_BUY: result= OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red);
break;
case OP_SELL: result= OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Red);
}
if(result==false)
{
Alert("Order ", OrderTicket(), "failed to close. Error", GetLastError() );
Sleep(3000);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Why is it that noone is willing to help me? :(
Dear qjol,
EVERYBODY is busy... yet there have been up to 100 replies to other people's topics since I posted my request? I don't think so!
I found my topic on the third page, meaning new topics and/or new replies have been so many, enough to push mine to the third page!
Well, I'm still waiting... still hopeful...
OrderSend(Symbol(),OP_BUY,Lot_Size,Bid,Permissible_Slippage,b-P1000,a+P100,NULL,0,0,Blue); } if (OrdersTotal()==1) { OrderSelect(OrderTicket(), SELECT_BY_POS, MODE_TRADES);You can't use OrderTicket(), etc, until after the OrderSelect. And if your selecting using a ticket number, you must select by ticket. Either
int ticket= OrderSend(... } if (OrdersTotal()==1) { OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES);
or
orderSend(... for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and symbol oo.price= OrderOpenPrice(); oo.ticket = OrderTicket();
jojweah:
Dear qjol, EVERYBODY is busy... yet there have been up to 100 replies to other people's topics since I posted my request? I don't think so! I found my topic on the third page, meaning new topics and/or new replies have been so many, enough to push mine to the third page! Well, I'm still waiting... still hopeful...
This is a forum not a help desk. People come by once a day on average. Your not ruler of the world. Don't expect instant gratification.
Dear qjol, EVERYBODY is busy... yet there have been up to 100 replies to other people's topics since I posted my request? I don't think so! I found my topic on the third page, meaning new topics and/or new replies have been so many, enough to push mine to the third page! Well, I'm still waiting... still hopeful...
WHRoeder: This is a forum not a help desk. People come by once a day on average. Your not ruler of the world. Don't expect instant gratification.
Dear WHRoeder,
If only you weren't retarded I would have said something terrible to you. Also, I don't want to get banned from this site. I also am not sure if English language is your first language... since you don't seem to know what SENTENCE STRESS is. So, I want to be lenient with you.
I was only responding to the "EVERYBODY IS BUSY" claim of my friend, qjol. I hope you get it now.
PS always take your medication before posting things on this site!
Dear WHRoeder,
If only you weren't retarded I would have said something terrible to you. Also, I don't want to get banned from this site. I also am not sure if English language is your first language... since you don't seem to know what SENTENCE STRESS is. So, I want to be lenient with you.
I was only responding to the "EVERYBODY IS BUSY" claim of my friend, qjol. I hope you get it now.
PS always take your medication before posting things on this site!
jojweah:
..... I want to be lenient with you.
..... I want to be lenient with you.
then y
jojweah:
......
PS always take your medication before posting things on this site!
......
PS always take your medication before posting things on this site!
It's not nice
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hello all,
Whenever my EA gets a buy signal, it (correctly) sends only one order. However, when it gets a sell signal, it always opens two sell orders (instead of one). Please, help me solve this problem.
I have copied the section of the BUY code, replaced OP_BUY with OP_SELL, still the same thing happens.
I have even added:
if (Sell_Signal==true && OrdersTotal()==0)
{
OrderSend(Symbol(),OP_SELL....);
}
...yet, after opening one sell order (and OrdersTotal() is now equal to 1), the EA usually sends another order (most times simultaneously... at the same price) thereby defying my instruction to only send the signal when OrdersTotal() equals 0
The BUY code is similar... but it obeys the instruction, sending ONLY ONE order:
if (Buy_Signal==true && OrdersTotal()==0)
{
OrderSend(Symbol(),OP_BUY....);
}
This is my plight.