Reputation: 15
I’m making an indicator where i want to sell at a loss or a profit. I’m using 2 ternary oparators.
when i try to plot the script , it tels me that it cannot call strategy.exit with arguments (literal string, stop=series,profit=series) available overloads`.
“I tried alot of variations, the problem is that i keep getting errors, like this one
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
Upvotes: 0
Views: 767
Reputation: 114
//@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)
Upvotes: 1
Reputation: 83
Not completely clear what you are trying to achiev with the "My,"Myt" element. Take them out and it works fine...
//@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)
Upvotes: 0