- How to set Order Filling Type?
- Deviation/slippage
- Rectangle to fill or not to fill?
It is called spread! You will always buy at a higher price and sell at a lower price. You buy at the Ask price and you sell at the Bid price.
That is not how trading works! You have two choices:
- You wait until the Ask price is at (or below) the price you want, and then place the market order, or ...
- you place a buy limit pending order and wait for it to be triggered at or below the price you want.
Then use the first option. Have your code monitor the Ask price, and if or when it reaches the price you want, then place the market buy order.
When you use pending orders, you have to check for the broker's Stops Levels and Freeze Levels limitations. For many brokers, you can't place a pending order too close to the current prices.
When you use pending orders, you have to check for the broker's Stops Levels and Freeze Levels limitations. For many brokers, you can't place a pending order too close to the current prices.
I dont think it is the case here. I got an order fulfilled. I have read somewhere on this forum that this error might occure when the market is closed
I have to solve the problem to close the pending order if is not valid anymore and I have no idea how to get only pending orders for the symbol
See the example code for "orders_get" to retrieve information on active orders and then use "order_send" with " TRADE_ACTION_REMOVE" to remove/delete the pending order.
However, I still advise you to use the first option instead of pending orders so close to the current market prices. Most brokers do not allow for that.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use