Hi,
In Turkey, there are certain stocks that trade with wider spread between Bid and Ask.
As one example, HALKB ticker is typically quoted as 10.00 / 10.05 during the day.
So, in a bid to capture this wider bid/ask spread in my strategy, I use:
CODE:
Please log in to see this code.
Interestingly however, these two identical order types (as per Quickref documentation) yield different Buy (And Sell) levels when used within the strategy.
If we continue from the same example:
* This code BUYS at 10.05 (when BUY signal is 10.00 TL) => Great, fine!
* This code however sells at 9.99 TL (when SELL signal is 10.00 TL) =>Wrong?!
This problem involves one hidden and very dangerous issue (other than the loss of just one-tick while selling the stock)
In fact, when the SELL price is calculated at 9.99 by the code:
- the strategy will execute this order ONLY WHEN the price AT NEXT BAR hovers around 9.95 / 10.00 (so that the code that can execute this SELL order at 9.99)
- that means, the code will execute this order ONLY WHEN it checks the NEXT BAR FIRST and sees if the price is moving down at the next bar
- So, that is front running (i.e. looking forward to next bar if the price falls, and, then, executing the order at 9.99 while the current bar price is 10.05 / 10.00.)
**
* Why is the calculation methodology between BuyAtStop and SellAtStop are different?
* Any remedies to prevent this `implicit` front running of the code?
Thanks in advance for your time and consideration,
Aykut Saribiyik