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

 

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

 
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.

 

No i know the concept of Ask and Bid and that's why I added the Ask instead of the Bid initially . 

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?

 
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. 
 
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?
 

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.


But for your error: 

//Can't do   
OrderSend(Symbol(),OP_BUY,lot_size,Open[0],2,Open[0]-SL*Point,Open[0]+TP*Point,0); 
//Can do: 
OrderSend(Symbol(),OP_BUY,lot_size,Ask,2,Ask-SL*Point,Ask+TP*Point,0); 


You can do an if statement:

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


I hope this helps