# Opening orders at the price of the close of the previous candle. - page 2

733

Well thanks for the corrections to my statement. (Keith and William)

Hernandez it is difficult to know what you trying to achieve, the picture is not showing much. If you are trying to buy at that point when the price has already moved by a few bars, this will not be possible. This is like trying to go back in time

Moderator
17654

Hernandez18:

The problem is the one listed in the photo below. If I put the Bid instead of Ask It gives me Error138

If you are unable to grasp the simple concept that you BUY at ASK and SELL at BID, then you should give up any idea of trading and coding.

46

I'm trying to find a way to open my order at the close price of the previous candle. Many traders do that. If you see in the photo the order price is too high with respect of the close of the previous candle, and I loose many important pips.

I understood that it is possible that the close price of the previous candle is never reached, right? But is there a way to open my order at a "more beautiful" price level?

733

You can either place a limit order and hope it gets it , but you cant buy at a price different to the current market price.
46

Brian Rumbles:
You can either place a limit order and hope it gets it , but you cant buy at a price different to the current market price.

Can I buy at the open of the current candle in some manner? If i replace the Ask with Open[0], it gives me error number 138

Anyway. Why my open is so high in the photo? Is it caused by the spread? Or something else?
733

The price you get will be higher due to the spread, use very low spread broker.

You can buy at the open as a point in time, but the price you will get will be the market price including spread.

```//Can't do
`if (Ask<= Close[1]){OrderSend(Symbol(),OP_BUY,lot_size,Ask,2,Ask-SL*Point,Ask+TP*Point,0); }`