def sell = ; #put your sell condition here
def buy = ; #put your buy condition here
AddOrder(OrderType.BUY_TO_OPEN, buy, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Buy");
AddOrder(OrderType.SELL_TO_CLOSE, sell, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "Sell");
def orderDir = CompoundValue(1, if buy then 1 else if sell then -1 else orderDir[1], 0);
def isOrder = orderDir crosses 0;
def curDaysCounter = if IsNaN(curDaysCounter[1]) and orderDir==1 and isOrder then 1 else if orderDir==1 then curDaysCounter[1]+1 else 0;
def recTradeCounter = if IsNaN(recTradeCounter[1]) and orderDir==1 and isOrder then 1 else if orderDir==1 then recTradeCounter[1]+1 else recTradeCounter[1];
def curDays = curDaysCounter;
def recDays = recTradeCounter;
AddLabel(1, "Current days: " + curDays, Color.GRAY);
AddLabel(1, "Most recent trade days: " + recDays, Color.GRAY);