我正在做一个指标。 问题是,当我将其添加到图表中时,出口无法正常工作。 当我买入指标时,买入后立即卖出一根蜡烛。
我正在指示我要亏本或卖出的位置。我正在使用2个三元遮盖剂。我叫longStop的另一个叫longProfit。我已经尝试过止损/限价/获利/亏损功能,但到目前为止,似乎没有一个起作用。
//@version=4
strategy("Daily ATR Stop", overlay=true)
//========================================================long entery.
high1 = high[100]
high2 = highest(high, 99)
long = float(na)
long := high2 < high1 ? high1 : long[1]
long_cond = crossover(close, long)
if long_cond
strategy.entry("My Long Entry Id", strategy.long)
//long profit//
low1 = low[30]
low2 = lowest(low,29)
longProfit = float(na)
longProfit := low1 < low2 ? low1 : longProfit[1]
atrLkb = input(7, minval=1, title='ATR Stop Period')
atrRes = input("D", type=input.resolution, title='ATR Resolution')
atrMult = input(1, step=0.25, title='ATR Stop Multiplier')
atr = security(syminfo.tickerid, atrRes, atr(atrLkb))
longStop = float(na)
longStop := long_cond and strategy.position_size <= 0 ? close - atr *
atrMult : longStop[1]
// i have a problem whith the exit part
strategy.exit("exit","My Long Entry Id", stop=longStop,
profit=longProfit)
plot(longProfit)
plot(longStop)
plot(long)