front = If(FrontLeg == 3, 3M, If(FrontLeg==2, 2Y, If(FrontLeg==5, 5Y, If(FrontLeg==7, 7Y, If(FrontLeg==10, 10Y, 30Y)))));
back = If(BackLeg == 3, 3M, If(BackLeg==2, 2Y, If(BackLeg==5, 5Y, If(BackLeg==7, 7Y, If(BackLeg==10, 10Y, 30Y)))));
curve = (back - front)*100;
lookback = lookback;
bullsteepener = If(curve > curve>>lookback && front < front>>lookback && back< back>>lookback, curve, 0);
bearsteepener = If(curve > curve>>lookback && front > front>>lookback && back> back>>lookback, curve, 0);
steepenertwist = If(curve > curve>>lookback && front < front>>lookback && back> back>>lookback, curve, 0);
bullflattener = If(curve < curve>>lookback && front < front>>lookback && back < back>>lookback, curve, 0);
bearflattener = If(curve < curve>>lookback && front > front>>lookback && back > back>>lookback, curve, 0);
flattenertwist = If(curve < curve>>lookback && front > front>>lookback && back < back>>lookback, curve, 0);