pine-scriptpine-script-v5pine-script-v6

Discrepancy between calling ta.dmi(14,14) directly vs when calling is from request.security


//@version=6 indicator("TestADXRequestSecurity", overlay = true)

[diPlus, diMinus, adx] = ta.dmi(14,14)

[tsladiplus, tsladiminus, tslaadx] = request.security("NASDAQ:TSLA" , timeframe.period, ta.dmi(14,14), lookahead = barmerge.lookahead_on)

log.info("ADX without Request Security: " + str.tostring(adx) + "ADX with Request Security: : " + str.tostring(tslaadx))

Source code


Solution

  • It's about the extended trading hours that you have enabled on your chart.

    When calling directly ta.dmi() it factors in the displayed extended trading hours bars.

    When requesting the ta.dmi() from the security, it does not include the extended trading hours. You could request them with ticker.modify().