Testing BUY/SELL on close price previous bar - page 2

 
RaptorUK:
There is no status to check, your variable status is the return value from OrderSend(), if it is less than 0 you have an error, do you then print the error to the log ? what error is it ?

What is the value of price compared to Bid at the time you try to place the order ?

The value of price is close prev bar.

..and i would after 5 minutes later buy/sell by ask/bid price, if the order by close price is failed. That way i would like to know order status

 
lukibest:

The value of price is close prev bar.

..and i would after 5 minutes later buy/sell by ask/bid price, if the order by close price is failed. That way i would like to know order status

If the Order failed you need to know why. If the Order may still be pending then Select the order and check it's OrderType().
 
Just so it is clear to us can you name what order status information you are seeking?
 
Ickyrus:
Just so it is clear to us can you name what order status information you are seeking?
I would like to know status order is it still pending or is it finished, one of this, to check what happen with this order.
 
lukibest:
I would like to know status order is it still pending or is it finished, one of this, to check what happen with this order.
OrderSelect() then check the OrderType()
 
RaptorUK:
If the Order failed you need to know why. If the Order may still be pending then Select the order and check it's OrderType().

int order_type;
  if(OrderSelect(12, SELECT_BY_POS)==true)
    {
     order_type=OrderType();
     // ...
    }
  else
    Print("OrderSelect() returned error - ",GetLastError());
"OP_BUYLIMIT - buy limit pending position" it will return buylimit is pending or not ? if yes then YOU HAVE GOOD POLISH BEER ;), i will check later...
 

Thank you is working...

One more question maybe stupid but I don't have experience on forex.


I have LONG position, why i can buy SHORT but i can not close LONG by the same price like SHORT ?



I mean i tested and i can close pos by price long but i can not close pos by short but i can take short

    switch (OrderType())
         {
            case 0:                                //close long 
               if( Bid >iClose(0,0,1))
               cena = Bid;
               else
               cena = iClose(0,0,1);            
               OrderClose(ticket, orderSize, cena, 3,Green);
               break;
                  
            case 1:                               //close short
               if( Ask < iClose(0,0,1))
                cena = Ask;
               else
                cena = iClose(0,0,1);            
               OrderClose(ticket, orderSize,cena, 3,Green);
               break;
         }
 
lukibest:

Thank you is working...

One more question maybe stupid but I don't have experience on forex.

I have LONG position, why i can buy SHORT but i can not close LONG by the same price like SHORT ?

I mean i tested and i can close pos by price long but i can not close pos by short but i can take short

To close a Buy a Sell is used, a Sell is placed at Bid. To close a Sell a Buy is used, a Buy is placed at Ask. So to close a Buy use Bid, to close a Sell use Ask. Or select the order using OrderSelect() and use OrderClosePrice(), it works for Buys and Sells.
 
RaptorUK:
To close a Buy a Sell is used, a Sell is placed at Bid. To close a Sell a Buy is used, a Buy is placed at Ask. So to close a Buy use Bid, to close a Sell use Ask. Or select the order using OrderSelect() and use OrderClosePrice(), it works for Buys and Sells.

As always you have right. THX
Reason: