gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
alpha_raw = if_else(industry_zscore > 0, reverse(slope), slope)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
alpha_raw = multiply(slope, reverse(industry_zscore))
alpha = rank(alpha_raw)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
signal = if_else(slope > 0, 1, if_else(slope < 0, -1, 0))
alpha = multiply(signal, industry_zscore)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
alpha_raw = ts_zscore(slope, 8)
alpha = reverse(alpha_raw)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
combined_score = add(industry_zscore, slope)
alpha = rank(combined_score)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
alpha_raw = multiply(industry_zscore, slope)
alpha_rank = rank(alpha_raw)
alpha = subtract(alpha_rank, 0.5)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
trend_strength = ts_std_dev(slope, 4)
alpha = multiply(slope, trend_strength)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
baseline = ts_mean(industry_zscore, 8)
alpha_raw = subtract(slope, baseline)
alpha = rank(alpha_raw)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
pos_alpha = if_else(industry_zscore <= 0, reverse(slope), multiply(slope, -1))
alpha = rank(pos_alpha)

gross_margin = divide(fnd6_acdo, fnd6_newqeventv110_spcepd12)
industry_zscore = group_zscore(gross_margin, swsector)
slope = ts_decay_linear(industry_zscore, 4)
raw_signal = if_else(industry_zscore > 0, if_else(slope < 0, 1, -1), if_else(slope > 0, 1, -1))
alpha = multiply(raw_signal, industry_zscore)