This is what I did but it doesn’t work
#
# TD Ameritrade IP Company, Inc. (c) 2009-2017
#
#wizard input: length1
#wizard text: -period
#wizard input: averageType1
#wizard text: crosses
#wizard input: crossingType
#wizard input: length2
#wizard text: -period
#wizard input: averageType2
#wizard text: Price:
#wizard input: price
input price = close;
input length1 = 15;
input length2 = 30;
input averageType1 = AverageType.Simple;
input averageType2 = AverageType.Simple;
input crossingType = {default above, below};
def avg1 = MovingAverage(averageType1, price, length1);
def avg2 = MovingAverage(averageType2, price, length2);
#deleted plot and added def to this line
def signal = crosses(avg1, avg2, crossingType == CrossingType.above);
def signaldown = crosses(avg1, avg2, crossingType == CrossingType.below);
#didnt think this stuff was necessary
#signal.DefineColor(“Below”, GetColor(7));
#signal.AssignValueColor(if crossingType == CrossingType.above then #signal.color(“Above”) else signal.color(“Below”));
#signal.SetPaintingStrategy(if crossingType == CrossingType.above
# then PaintingStrategy.BOOLEAN_ARROW_UP
# else PaintingStrategy.BOOLEAN_ARROW_DOWN);
addOrder(OrderType.BUY_AUTO, signal);
#added this line to sell
addOrder(OrderType.SELL_AUTO, signal);
without going into much detail, I immediately found you are using the same condition for buy and for sell. the variable named ”signal” is used for both. That will never work. The buy and sell conditions that you use in your AddOrder() statements need to be completely different.