0

Afternoon, I am trying to write a simple strategy to open a long trade intra-candle and not at close. I've tried a few settings that didn't work so stripped the script down to a dummy sample. The code below opens the long at the close of the candle and not somewhere around 15343 as I'd expect. I thought this was the point of the calc_on_every_tick setting but it appears to do nothing.

//@version=5
strategy(title = 'Simple Strategy', shorttitle = 'Simple Strategy', overlay = true, calc_on_every_tick = true) 

if(ta.crossover(15343, low))
    strategy.entry(id = "Long", direction = strategy.long, qty = 1, stop = 5, comment = str.tostring(close))
user2883072
  • 217
  • 3
  • 12

1 Answers1

0

calc_on_every_tick will just make your script to be executed on each tick. It has nothing to do with when your order is filled.

By default, Tradingview will use market orders. If you want to enter a trade intrabar, you need to place a limit order.

You can use the limit or stop argumentes of the strategy.entry().

limit (series int/float) An optional parameter. Limit price of the order. If it is specified, the order type is either 'limit', or 'stop-limit'. 'NaN' should be specified for any other order type.

stop (series int/float) An optional parameter. Stop price of the order. If it is specified, the order type is either 'stop', or 'stop-limit'. 'NaN' should be specified for any other order type.

vitruvius
  • 15,740
  • 3
  • 16
  • 26