Suppose I have this code to calculate SMIsignal , emasignal .
//@version=4
study("test", overlay=true)
a = 20
b = 2
ob = 40
os = -40
// Range Calculation
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
////////////////////////////////////////
SMIsignal = ema(SMI,b)
emasignal = ema(SMI, 10)
Trading view will calculate the value for the timeframe used in Tradingview e.g. 20 minutes . What code should I use if I would calculate SMIsignal and emasignal for a different timeframe for example 7 minutes ?
use security
function
example:
// both in same timeframe but the chart in different timeframe
[_smi, _ema] =security(syminfo.tickerid, "7", [SMIsignal, emasignal])
or
// 7-min resolution
_smi = security(syminfo.tickerid, "7", SMIsignal)
// 20-min resolution
_ema = security(syminfo.tickerid, "20", emasignal)
for more information check https://www.tradingview.com/pine-script-reference/#fun_security
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments