i wanna open a sell order after 20 pip of the opening price of a buy order ..after checking out the value of the OrderOpenPrice() its correct ..
can u guys please take a look and see where im missing it ?? thank u in advance
if (TotalOrderCount() >0) return(0);
Assuming that this function counts open orders
If there is at least 1 open order, none of the following code will be executed
Please use correct English, if you mean "you" write "you", not "u".
Not all posters are native English speakers and may not understand such abbreviations.
int orders=0; for (int i=0; i<OrdersTotal(); i++){ if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) if(OrderSymbol()==Symbol()) orders++; } if(orders==0) {
double OP_price = OrderOpenPrice(); if( Buy1 >0 && (Bid < (OP_price-20*pte)) ) Alert("Open price " , OP_price ); //S = OrderSend(Symbol(),OP_SELL,2*lot,Bid,Slippage,0,Bid-TP*pte,"",MagicNumber,0,Red);
how i gone make this condition right ? i want it to open a new order after it hit 20 pip under the order open price ...please can you help me with that ?
thank you for your help
thank you GumRai for your notice ..its working now....but the serious problem still remaining
how i gone make this condition right ? i want it to open a new order after it hit 20 pip under the order open price ...please can you help me with that ?
thank you for your help
the problem is : the expert does not respect this condition
if( Buy1 >0 && (Bid < (OP_price-20*pte)) )
i even tried serval things like :
using this form
OP_price-Bid >= 20*pte
or even tried to select the order :
Buy1 = OrderSend(Symbol(),OP_BUY,lot,Ask,Slippage,0,Ask+TP*pte,"",MagicNumber,0,Green); ///////////////////////////////////////////////////////////////////////////////////// if(OrdersTotal()>0){ for(pos=OrdersTotal();pos>=0;pos--){ double resuet=OrderSelect(pos,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_BUY && OrderSymbol()==Symbol()){ double OP_price = OrderOpenPrice(); if(Buy1>0) if(OrderSelect(Buy1,SELECT_BY_TICKET,MODE_TRADES)){ // here i tried to select the order .. if( (OP_price-Bid > 20*pte) ){ Alert("Open price " , OP_price ); //S = OrderSend(Symbol(),OP_SELL,2*lot,Bid,Slippage,0,Bid-TP*pte,"",MagicNumber,0,Red);
but always the same result .. no application of the "Alert" or the "S=OrderSend(Symbol(),OP_SELL,...."
Why are you looping through the orders when you know the ticket number?
B=OrderSend(Symbol(),OP_BUY,lot,Ask,Slippage,0,Ask+TP*pte,"",MagicNumber,0,Green); ///////////////////////////////////////////////////////////////////////////////////// if(B>0) { if(OrderSelect(B,SELECT_BY_TICKET)) { // here i tried to select the order .. if((OrderOpenPrice()-Bid>20*pte)) { Alert("Open price ",OrderOpenPrice()); //S = OrderSend(Symbol(),OP_SELL,2*lot,Bid,Slippage,0,Bid-TP*pte,"",MagicNumber,0,Red); } } }
Assuming that B is a globally declared variable. If it is locally declared, then it will not have kept the correct value for the following ticks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use