admin管理员组文章数量:1416322
Say I have a price on USD/CAD of 1.44426. When price closes below that line, I want to be ready for a trade long. If there is a candle with its whole body (open and close prices) under the line, it is the signal candle. On the very next candle, if price crosses above the highest part of that body (I'm using math.max(open,close)) I want it to enter long at the math.max of the body.
This works fine if it takes the trade on that very next candle. However, if say, there are 5 candles that do not cross the entry price I want the order to be canceled every candle and reset the entry price to that new candle's math.max of the body.
Currently no matter what I try, it holds the value of the first candle as the entry price and many candles later it will take the entry as price makes it back to that entry price.
strategy("Test 1-31-25", overlay = true, max_bars_back = 4000, calc_on_every_tick = true, pyramiding = 10)
line = 1.44426
plot(line, color = color.fuchsia)
// Turn the trading on
tradeStaged = 0
tradeStaged := close < line and close[1] > line ? 1 : tradeStaged[1]
// plot(tradeStaged)
// The signal
signal = math.max(open,close) < line
barcolor(signal ? color.lime : na)
// The entry price is established
entry = 0.0
entry := signal ? math.max(open, close) : na
if signal and tradeStaged == 1
strategy.entry("B", strategy.long, qty = 10000, stop = entry)
tradeStaged := 0
strategy.exit("XB", from_entry = "B", profit = 50, loss = 50)```
本文标签: Pine script disregard order entry and take next entryStack Overflow
版权声明:本文标题:Pine script disregard order entry and take next entry - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745250909a2649816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论