##Template for counting strategies
#Updated: 4.25.2020 by DeftMove - gkc
#Negative and positive winrate represented by DOLLAR AMOUNT P/L in report above/below zero
#PLACE STUDIES HERE
input tradeLot = 1; #hint tradeLot: Number of shares per order.
input analyzeWR = yes; #hint analyzeWR = if YES, dollar amounts P/L in report above/below zero are considered win/loss discrepancy. if NO, dollar amounts P/L in report are considered P/L
input runBuyAnalysis = yes; #hint runBuyAnalysis: if YES, run upward plays, if NO, prevent upward plays
def entryConditionBuy = ; #edit for each strategy, UP ENTRY CONDITIONS
def exitConditionBuy = ; #edit for each strategy, UP EXIT CONDITIONS
def exitGoodBuy = open[-1] > EntryPrice();
def exitBadBuy = open[-1] < EntryPrice();
AddOrder(OrderType.BUY_TO_OPEN, condition = entryConditionBuy and runBuyAnalysis, price = open[-1], tradeLot, name = "BuyOpen " + open[-1]);
AddOrder(OrderType.SELL_TO_CLOSE, runBuyAnalysis and exitConditionBuy and exitGoodBuy, price = if analyzeWR then EntryPrice() + 1 else open[-1], tradeLot, name = "SellClose " + open[-1] + "P/L: " + (open[-1] - EntryPrice()));
AddOrder(OrderType.SELL_TO_CLOSE, runBuyAnalysis and exitConditionBuy and exitBadBuy, price = if analyzeWR then EntryPrice() - 1 else open[-1], tradeLot, name = "SellClose " + open[-1] + "P/L: " + (open[-1] - EntryPrice()));
input runSellAnalysis = yes; #hint runSellAnalysis: if YES, run downward plays, if NO, prevent downward plays
def entryConditionSell = ; #edit for each strategy, DOWN ENTRY CONDITIONS
def exitConditionSell = ; #edit for each strategy, DOWN EXIT CONDITIONS
def exitGoodSell = open[-1] < EntryPrice();
def exitBadSell = open[-1] > EntryPrice();
AddOrder(OrderType.SELL_TO_OPEN, condition = entryConditionSell and runSellAnalysis, price = open[-1], tradeLot, name = "SellOpen " + open[-1]);
AddOrder(OrderType.BUY_TO_CLOSE, runSellAnalysis and exitConditionSell and exitGoodSell, price = if analyzeWR then EntryPrice() - 1 else open[-1], tradeLot, name = "BuyClose " + open[-1] + "P/L: " + (EntryPrice() - open[-1]));
AddOrder(OrderType.BUY_TO_CLOSE, runSellAnalysis and exitConditionSell and exitBadSell, price = if analyzeWR then EntryPrice() + 1 else open[-1], tradeLot, name = "BuyClose " + open[-1] + "P/L: " + (EntryPrice() - open[-1]));