# problem with order open price

41
2016.10.16 00:48
hi guys ..i have some troubles with this block of codes ..
```int init() {

////////////////////////////////////////////////////////////////////////////
if(MarketInfo(Symbol(), MODE_DIGITS)==3||MarketInfo(Symbol(), MODE_DIGITS)==5)
mypoint=10;
else mypoint=1;
pte=Point*mypoint;

return (0);
///////////////////////////////////////////////////////////////////////////
}
int start()
{

if (TotalOrderCount() >0) return(0);

if(OrdersTotal()>0){
for(pos=OrdersTotal();pos>=0;pos--){

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);

}}}

}

return (0);
}```
41
2016.10.16 00:52

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

Moderator
9639
2016.10.16 01:07
`  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.

41
2016.10.16 21:08
ok i used this block to open one order only ( if i remove it ..it open an infinity of the same order) .. if you have a better way to do it please show me ..
``` int orders=0;
for (int i=0; i<OrdersTotal(); i++){
if(OrderSymbol()==Symbol())
orders++;
}
if(orders==0)
{ ```
Moderator
9639
2016.10.16 23:44
Amin0xy:
ok i used this block to open one order only ( if i remove it ..it open an infinity of the same order) .. if you have a better way to do it please show me ..
Check the OrderType() in your loop.
41
2016.10.17 23:19
thank you GumRai for your notice ..its working now....but the serious problem still remaining
``` 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 ?

Moderator
9639
2016.10.17 23:50
Amin0xy:
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 ?

What is the problem?
41
2016.10.18 00:29

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 OP_price = OrderOpenPrice();

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,...."

Moderator
9639
2016.10.18 00:45

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))
{