Benjaminsabe
New member
Hey. I want to have a plot line that indicates where the trailing stop is going in relation to the price. I have as a reference the ATRTRAILINGSTOP study. Here's a picture of how it looks.
The problem is this plot is related to ATR values, not simple values like % or price differences like a simple trailing stop
I tried mixing it up with the TrailingStopLX, here's what I did
But no plot appears in the chart. Does anyone have any idea what I can do?
The problem is this plot is related to ATR values, not simple values like % or price differences like a simple trailing stop
I tried mixing it up with the TrailingStopLX, here's what I did
Code:
plot Data = close;
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));
plot TrailingStop = trailStopPrice;
TrailingStop.SetPaintingStrategy(PaintingStrategy.POINTS);
TrailingStop.DefineColor("Buy", GetColor(0));
TrailingStop.DefineColor("Sell", GetColor(1));
But no plot appears in the chart. Does anyone have any idea what I can do?