Please, help me solve EA problem

 

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.

 

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? :(
 
Everyone is busy with competition @ the ATC 2010
 
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...
 

You have an incorrect bracket on the 6 line of the short code. Remove that bracket.

V


 
 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.
 
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!
 
jojweah:
..... I want to be lenient with you.


then y

jojweah:
......
PS always take your medication before posting things on this site!

It's not nice