FlowscopeDocs

B012

processOrdersOnClose combined with the bar magnifier

Severity Warning

With processOrdersOnClose = true, market orders fill at the close of the bar that triggered them, and the bar magnifier (magnifier = true, the default when minute data exists) walks the real one-minute path inside each bar for limit and stop orders. Together, the decision and the fill happen on the same closing price while intrabar stops are checked minute by minute; the results can look better than what a live account would achieve.

Turn one of the two off. For realistic fills keep the magnifier and fill market orders at the next open (processOrdersOnClose = false). The script still runs; this is a warning.

Failing example

Flowscope Script
script "Close fills"
strategy (
  processOrdersOnClose = true
  magnifier = true
)
data chart = subscribe(data.ohlcv)
on chart.close {
  if ta.crossover(chart.close, ta.ema(chart.close, 34)) {
    strategy.entry("Long", direction.long)
  }
  strategy.exit("Stop", from: "Long", loss: 120.0)
}

Fixed example

Flowscope Script
script "Close fills"
strategy (
  processOrdersOnClose = false
  magnifier = true
)
data chart = subscribe(data.ohlcv)
on chart.close {
  if ta.crossover(chart.close, ta.ema(chart.close, 34)) {
    strategy.entry("Long", direction.long)
  }
  strategy.exit("Stop", from: "Long", loss: 120.0)
}