@FOTM_8888 Here is the modified version of the default MACD backtesting strategy in ToS. I added the SMA above 200 as a condition as the video instructed.
This is for long trades only.
This is for long trades only.
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2013-2020
#
input price = close;
input length = 200;
input displace = 0;
def SMA = Average(price[-displace], length);
def cond = close > SMA;
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
def diff = reference MACD(fastLength, slowLength, macdLength, averageType).Diff;
AddOrder(OrderType.BUY_TO_OPEN, diff crosses above 0 and cond, tickColor = GetColor(0), arrowColor = GetColor(0), name = "MACDStratLE");
AddOrder(OrderType.SELL_TO_CLOSE, diff crosses below 0, tickColor = GetColor(1), arrowColor = GetColor(1), name = "MACDStratSE");