Greetings All,
I’m trying to plot the trail stop strategy ( available on thinkorswim platform) but not clear on the logic. The variable to be plotted is “trailStopPrice”. Would like to get some help !
Thank you in advance!
AP
#
# TD Ameritrade IP Company, Inc. (c) 2011-2024
#
input trailStop = 1.0;
input offsetType = {default percent, value, tick};
def entryPrice = entryPrice();
def price = if IsNaN(entryPrice[1]) then entryPrice else if !IsNaN(entryPrice) then Max(high, price[1]) else entryPrice;
def mult;
switch (offsetType) {
case percent:
mult = price / 100;
case value:
mult = 1;
case tick:
mult = tickSize();
}
def trailStopPrice = price - trailStop * mult;
addOrder(OrderType.SELL_TO_CLOSE, low <= trailStopPrice, tickColor = GetColor(0), arrowColor = GetColor(0));
I’m trying to plot the trail stop strategy ( available on thinkorswim platform) but not clear on the logic. The variable to be plotted is “trailStopPrice”. Would like to get some help !
Thank you in advance!
AP
#
# TD Ameritrade IP Company, Inc. (c) 2011-2024
#
input trailStop = 1.0;
input offsetType = {default percent, value, tick};
def entryPrice = entryPrice();
def price = if IsNaN(entryPrice[1]) then entryPrice else if !IsNaN(entryPrice) then Max(high, price[1]) else entryPrice;
def mult;
switch (offsetType) {
case percent:
mult = price / 100;
case value:
mult = 1;
case tick:
mult = tickSize();
}
def trailStopPrice = price - trailStop * mult;
addOrder(OrderType.SELL_TO_CLOSE, low <= trailStopPrice, tickColor = GetColor(0), arrowColor = GetColor(0));