我正在指示我要亏本或卖出的位置。 我正在使用2个三元隔离符。
当我尝试绘制脚本时,它告诉我它不能调用带有参数(文字字符串,stop = series,profit = series)可用重载的strategy.exit。
“我尝试了很多变体,问题是我不断出错,就像这样
Cannot call strategy.exit with arguments (literal string,literal
string,literal string, stop=series[float],limit=series[float], string string
availeble overloads : strategy.exit(cont stringmstring
series[float],series[float].series[dool]) =>void.”
//@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)
ll = float(na)
ll := low1 < low2 ? low1 : ll[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("My Long Entry Id","My Long","ntry Id", stop=longStop,
profit=ll)
plot(longStop)
plot(ll)
plot(long)
line 25: Cannot call strategy.exit with arguments (literal string ,
literal string , literal string stop= series[float] profit= series[float]
available overloads strategy.exit
string string series[float], series[float] series series series[bool] =>
void
答案 0 :(得分:1)
//@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("long", strategy.long)
//long profit//
low1 = low[30]
low2 = lowest(low, 29)
ll = float(na)
ll := low1 < low2 ? low1 : ll[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","long", stop=longStop, profit=ll)
plot(longStop)
plot(ll)
plot(long)
答案 1 :(得分:0)
尚不完全清楚您要使用“ My,” Myt“元素实现的目标。将它们取出即可正常工作...
//@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)
ll = float(na)
ll := low1 < low2 ? low1 : ll[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("My Long Entry Id", stop=longStop, profit=ll)