gross_margin = divide(fnd6_newqeventv110_spceepsq, fnd6_newqeventv110_spcedq)

industry_zscore = group_zscore(gross_margin, group_sw)

zscore_trend = ts_regression(industry_zscore, ts_step(1), 4, 0, 0)

revenue_growth = ts_delta(fnd6_newqeventv110_spcedq, 4)

signal = if_else(revenue_growth >= 0, zscore_trend, 0)

ranked_signal = rank(signal)

final_alpha = subtract(ranked_signal, 0.5)