最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Pine script disregard order entry and take next entry - Stack Overflow

programmeradmin0浏览0评论

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)```
发布评论

评论列表(0)

  1. 暂无评论