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);
I just added this strategy to my chart and it does reverse the position. This strategy goes from long to short and back to short, always in a position. Did you meaning something else?
oh i guess it does! haha thanks