op_buy not work

 

hi every one

i have this expert open orders when no orders open and if current order is loss EA open new order

EA use this code ordertotal()==0 to check no orders open to start work but i need to change this code ordertotal()==0 to check if any buy orders was opened,

any one cn hlp

i try to use OrderType()!=OP_BUY but in this case not open any orders


please advice

bool buycondition;
buycondition=Close[1]>Open[1];
if(OrdersTotal()==0)

{
OrderSend(Symbol(),OP_BUY,lots,Ask,3,sl,tp,"s_03",1013,0,Green);//--open sell order

}


if (buycondition==true)

    OrderSelect(OrdersTotal()-1, SELECT_BY_POS, MODE_TRADES);  
    if(OrderSymbol()==Symbol() && OrderType()==OP_BUY  
    &&buycondition==true&& OrdersTotal()<max_of_open_lots&& Bid<=(OrderOpenPrice()-neworder*Point*10))
OrderSend(Symbol(),OP_BUY,0.2,Ask,3,sl,tp,"s_04",1013,0,Red);//--open sell order


   return(0);
 
verofx:

hi every one

i have this expert open orders when no orders open and if current order is loss EA open new order

EA use this code ordertotal()==0 to check no orders open to start work but i need to change this code ordertotal()==0 to check if any buy orders was opened,

any one cn hlp

i try to use OrderType()!=OP_BUY but in this case not open any orders

You need a loop to loop through all the open orders, and check if any are OrderType() == OP_BUY . . .

You also need to check the return values from your trading functions to see if they have worked or failed, if they fail you will want to know about it, you will want to know why they failed - the error, and what made them fail - the relevant variables involved such as Bid, Ask Open price, etc, etc read this and implement it: What are Function return values ? How do I use them ?

 
RaptorUK:

You need a loop to loop through all the open orders, and check if any are OrderType() == OP_BUY . . .

You also need to check the return values from your trading functions to see if they have worked or failed, if they fail you will want to know about it, you will want to know why they failed - the error, and what made them fail - the relevant variables involved such as Bid, Ask Open price, etc, etc read this and implement it: What are Function return values ? How do I use them ?


i try using OrderType()!=OP_SELL and work fine, only OrderType()!=OP_BUY not work the last code i submit with ordertotl()==0 work fine i replace this coed by OrderType()!=OP_BUY


bool buycondition;
buycondition=Close[1]>Open[1];
if(OrderType()!=OP_BUY)

{
OrderSend(Symbol(),OP_BUY,lots,Ask,3,sl,tp,"s_03",1013,0,Green);//--open sell order

}


if (buycondition==true)

    OrderSelect(OrdersTotal()-1, SELECT_BY_POS, MODE_TRADES);  
    if(OrderSymbol()==Symbol() && OrderType()==OP_BUY  
    &&buycondition==true&& OrdersTotal()<max_of_open_lots&& Bid<=(OrderOpenPrice()-neworder*Point*10))
OrderSend(Symbol(),OP_BUY,0.2,Ask,3,sl,tp,"s_04",1013,0,Red);//--open sell order


   return(0);
 
verofx:

i try using OrderType()!=OP_SELL and work fine, only OrderType()!=OP_BUY not work the last code i submit with ordertotl()==0 work fine i replace this coed by OrderType()!=OP_BUY


If you want help listen to the help you are given . . .
 
RaptorUK: If you want help listen to the help you are given . . .
He's hard of reading!
 
may i ask you for loop code do this function?
 
verofx:
may i ask you for loop code do this function?
You can find sample code here: Loops and Closing or Deleting Orders
 
bool buycondition;
buycondition=Close[1]>Open[1];
int j;
for(j=1;j<=OrdersTotal(); j++)

OrderSelect(OrdersTotal()-1, SELECT_BY_POS, MODE_TRADES);  

if (buycondition==true&&OrderType()!=OP_BUY)

{
OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"buy_0",0,0,Red);//--open sell order
}

OrderSelect(OrdersTotal()-1, SELECT_BY_POS, MODE_TRADES);  
    if(OrderSymbol()==Symbol() && OrderType()==OP_BUY  
    &&buycondition==true&& OrdersTotal()<max_of_open_lots&& Ask<=(OrderOpenPrice()-neworder*Point*10))
OrderSend(Symbol(),OP_BUY,0.2,Bid,3,0,0,"s_02",0,0,Red);//--open sell order

i use loop as i suit but no any order opened

pleae advice

 
verofx:

i use loop as i suit but no any order opened

pleae advice


If you can't think logically about coding then your best option is here, pay someone to code for you: Jobs