I am currently working on a variation of the vix timing strategy in TOS. I want to add trailing stops to the code but when i do, a new order is added after the trailing stop closes the position due to the condition still being met. Does anyone have any idea how I could rework this? It is driving me crazy that TD does not have a dedicated support team.
I attached my code below.
Thanks,
I attached my code below.
Thanks,
Code:
input PriceType = FundamentalType.LOW;
input EmaLength = 10;
input TrendLength = 11;
input Period1 = AggregationPeriod.FIFTEEN_MIN;
def priceVix = Fundamental(PriceType, "VIX", Period1);
def emaVix = ExpAverage(priceVix, EmaLength);
AddOrder(OrderType.BUY_AUTO, Sum(priceVix < emaVix, TrendLength)[1] == TrendLength, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Long");
AddOrder(OrderType.SELL_AUTO, Sum(priceVix > emaVix, TrendLength)[1] == TrendLength, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "Short");