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

Say I have a price on USDCAD of 1.44426. When price closes below that line, I want to be ready for a t

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)```

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745250909a4618671.html

相关推荐

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

    Say I have a price on USDCAD of 1.44426. When price closes below that line, I want to be ready for a t

    11小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信