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 ?
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);
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
may i ask you for loop code do this function?
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
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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