My problem is at the bottom. I am trying to make a plot color in blue for a positive number, red for a negative number, and black if zero.
I keep getting a variety of errors as I try to manipulate the script to work. I have no scripting experience except what you see. I have been working on trial and error to get my results.
//@version=2
//Move Score is average 4 most recent weeks (weekly price movement - [high-low])
//Used to find stocks that move well last month.
//BBwidth tells us the difference between BB high and BB low (showing possible dollar movement)
//NoGo gives us the size of the BBwidth compared to MS89 (must be at least 5x larger to consider trading)
//RSI is added to minimize the need for multiple indicators
study(title = "Complicated Move Score", shorttitle= "MSS | MSL | 5x+ | RSI | EMA-SMA")
len = input(1, minval=1, title="Short MS Length")
lengthL = input(89, minval=1, title="Long MS Length")
src = input(close, title="Source")
length = input(20, minval=1, title="BB Length")
mult=input(2.0, minval=0.001, maxval=50, title= "Mult")
basis=sma(src, length)
dev=mult * stdev(src, length)
x = high-low
MS = sma(x,len)
MSL = sma(x,lengthL)
upper = basis + dev
lower = basis - dev
BBwidth = upper - lower
NoGo = BBwidth / MSL //this is the BBwidth / Longer MS
plot(MS, style=circles)
plot(MSL, style=circles)
plot(NoGo, color=red, style=circles)
RSIsrc = close, RSIlen = input(20, minval=1, title="Length")
up = rma(max(change(RSIsrc), 0), RSIlen)
down = rma(-min(change(RSIsrc), 0), RSIlen)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=purple, style=circles) //This is the standard RSI score
lenEMA = input(8, minval=1, title="EMA")
lenSMA = input(13, minval=1, title="SMA")
outEMA= ema(src, lenEMA)
outSMA= sma(src, lenSMA)
MAx = outEMA - outSMA
plot(MAx, color=black, style=circles) //use this until my if/else works
//Plot Colors, Trying to make MAx color blue when positive and red when negative, black if zero
col_Red = #FF0000
col_Blue = #0000FF
plot(MAx, title="+/- Indicator", style=circles, color = if(MAx>0)
MAx = col_Blue
elif (MAx<0)
MAx = col_Red
elif (MAx = 0)
MAx = black)
Aucun commentaire:
Enregistrer un commentaire