Alright so I am creating a trading system on pinescript and I keep running into a undeclared identifier error and I also get an error that says that I need an output function for the strategy show on the graph, here is my code:
strategy(title ="My Long term strategy", overlay=true)
//DEFINITIONS
shortMa = ema(close,8)
longMa = ema(close, 14)
//MACD indicator
macdShort = input(12, minval=1, title ="MACD Fast length")
macdLong = input(26, minval=1, title = "MACD Slow Length")
macdSignal = input(9, minval=1, title = "MACD Signal Length")
mac= macd(close,macdShort, macdLong, macdSignal)
MACDLine= (macdShort - macdLong)
//SignalLine= 9
//MACDHistogram: MACDLine - SignalLine
//Stochastic indicator
Length = input(14, minval = 1, title = "stochastic Length")
k= input(3,minval = 1, title= "stochastic%k")
d= input(3,minval = 1, title= "stochastic%d")
sto = stoch(close,highest(Length),lowest(Length), Length)
stoUppper = hline(80, title="Upper Limit",color=color.red, linestyle=hline.style_dotted)
stoLower = hline(20, title="Lower Limit", color=color.lime, linestyle=hline.style_dotted)
//VWAP indicator
v = vwap(hlc3)
// RSI indicator
src = close
RSIlen = input(14, minval=1,title="RSI length")
EMAlen =input(10, minval=1 , title = "RSI EMA Length")
Up = rma(max(change(src),0), RSIlen)
Down = rma(-min(change(src), 0), RSIlen)
rsi= Down == 0 ? 100: Up == 0 ? 0:100 -(100/(1+Up/Down))
RSIEMA = ema(rsi,EMAlen)
band1 = hline(70, color=color.red, title = "Upper Line", linestyle=hline.style_solid)
band0 = hline(30, color=color.lime, title = "Lower Line", linestyle=hline.style_solid)
//LOGIC
longsignal = crossover(shortMa, longMa)
macdlong = crossover(macdline, macdSignal)
stolong = crossover(k and d, lowerlimit)
vlong = crossover(close,v)
RSIlong = crossover(rsi and RSIEMA, band0)
//POSITIONS
strategy.entry(id = "longPosition", long=true, when=longsignal and macdlong and stolong and vlong and RSIlong)
Can someone plz take a look at the code above and tell me how to fix the errors?