'limit order placed at wrong price pine script
I tried to use a simple CCI as long and short entries. And for long entries I would like to have limit order of 1% less than the trigger price. However, the actual price is very different from the trigger price without the limit order. For instance, if the buy entry price is 100(using code without limit order), the buying price with limit order should be 99, but in reality it's 92.3. What I did wrong?
//@version=5
strategy(title='test', overlay=false, pyramiding=0)
///CCI Source Code///
length = input.int(200, minval=1)
src = close
ma = ta.sma(src, length)
cci = (src - ma) / (0.015 * ta.dev(src, length))
plot(cci, "CCI", color=color.blue)
///long/short entry///
if cci > 0
strategy.entry("Long", strategy.long, limit=close * 0.99)
if cci < 0
strategy.cancel("Long")
if cci < 0
strategy.entry("Short", strategy.short)
Thanks ahead for your help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
