def BuySignal = if BuyDiff crosses above 0 then 1 else 0;
def SellSignal = if SellDiff crosses below 0 then 1 else 0;
AddOrder(OrderType.BUY_TO_OPEN, RTH and (BuySignal + BuySignal[-1]) / 2, price = BuyorderPrice, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "CDS_LE_G");
AddOrder(OrderType.SELL_TO_CLOSE, (SellSignal + SellSignal[-1]) / 2, price = SellorderPrice, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "CDS_SE");
or
AddOrder(OrderType.BUY_TO_OPEN, RTH and BuySignal[-1], price = BuyorderPrice, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "CDS_LE_G");
AddOrder(OrderType.SELL_TO_CLOSE, SellSignal[-1], price = SellorderPrice, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "CDS_SE");