In this snippet of a combined indicator code with conditions bullish, bearish, and PriceAboveEMA and AddOrder commands, everything runs fine with PriceAboveEMA, but it seems the code is not executed to my intention. PriceAboveEMA condition does not affect the AddOrder, it is ignored. I'm having trouble troubleshooting.
Am I missing something, or getting something backwards?
bullish, bearish, and rth conditions work fine and their conditions are omitted from this post due to the length of the script.
'''
#other code above removed
input EMAlength2 = 200
def PriceAboveEMA = if MovAvgExponential(EMAlength2) is less than close then 1 else 0;
# Bullish Orders
AddOrder(OrderType.BUY_TO_OPEN, condition = PriceAboveEMA and bullish and bullish[2] and rth==1, price = open[-1], Tradesize = TRADESIZE, arrowcolor = Color.CYAN, name = " ");
AddOrder(OrderType.SELL_TO_CLOSE, condition = bearish and rth==1, price = open[-1], Tradesize = TRADESIZE, arrowcolor = Color.RED, name = " ");
'''
Am I missing something, or getting something backwards?
bullish, bearish, and rth conditions work fine and their conditions are omitted from this post due to the length of the script.
'''
#other code above removed
input EMAlength2 = 200
def PriceAboveEMA = if MovAvgExponential(EMAlength2) is less than close then 1 else 0;
# Bullish Orders
AddOrder(OrderType.BUY_TO_OPEN, condition = PriceAboveEMA and bullish and bullish[2] and rth==1, price = open[-1], Tradesize = TRADESIZE, arrowcolor = Color.CYAN, name = " ");
AddOrder(OrderType.SELL_TO_CLOSE, condition = bearish and rth==1, price = open[-1], Tradesize = TRADESIZE, arrowcolor = Color.RED, name = " ");
'''
Last edited: