Hello,
i am trying to search for companies where the tenkan crosses above the kijun, however, the scan below is just not working. Any ideas or modifications to make it work would be appreciated
i am trying to search for companies where the tenkan crosses above the kijun, however, the scan below is just not working. Any ideas or modifications to make it work would be appreciated
Ruby:
input tenkan_period = 9;
input tenkan_mult = 2.0;
input kijun_period = 21;
input kijun_mult = 4.0;
script _avg {
input src = close;
input length = 9;
input mult = 2;
def _atr = ATR(length) * mult;
def up = hl2 + _atr;
def dn = hl2 - _atr;
def upper = if src[1] < upper[1] then Min(up, upper[1]) else up;
def lower = if src[1] > lower[1] then Max(dn, lower[1]) else dn;
def os = if src > upper then 1 else if src < lower then 0 else os[1];
def spt = if os == 1 then lower else upper;
def _max = if src crosses spt then Max(src, _max[1]) else if os == 1 then Max(src, _max[1]) else spt;
def _min = if src crosses spt then Min(src, _min[1]) else if os == 0 then Min(src, _min[1]) else spt;
plot return = (_max + _min) / 2;
}
def Tenkan = _avg(close, tenkan_period, tenkan_mult);
def Kijun = _avg(close, kijun_period, kijun_mult);
plot BullishScan = Tenkan crosses above Kijun;
Last edited by a moderator: