This worked. I made a script that can plot multiple RSI lines of different symbols. The colour of the plot is green if the RSI value is below 30, and red if it is above 70. You can just copy the rows and add more symbols. I think the maximum number of stocks to plot is 40. You should also be able to add Alerts in the get_color_rsi().
Code: Select all
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CanYouCatchMe
//@version=4
study("My Script")
get_color_rsi(value) =>
c = color.blue
if (value < 30)
//Alert: buy
c:=color.green
else if (value > 70)
//Alert: sell
c:=color.red
c //Returning color
rsi_value = rsi(security("BTCUSD", timeframe.period, close), 14)
plot(rsi_value, color=get_color_rsi(rsi_value))
rsi_value := rsi(security("OMXS30", timeframe.period, close), 14) //Note: You need a := when assigning rsi_value again.
plot(rsi_value, color=get_color_rsi(rsi_value))
rsi_value := rsi(security("DAX", timeframe.period, close), 14)
plot(rsi_value, color=get_color_rsi(rsi_value))
I tried to make a string array of many symbols and then plotting them. When I tried to get a value from the array it returned a variable of the type "series[string]". The plot function only accepts a "sting", not a "series[string]".
The code that did not work:
Code: Select all
var a = array.new_string()
array.push(a, "OMXS30")
plot(security(array.get(a,0), timeframe.period, close)) //Error: "Cannot call 'security' with 'symbol'=series[string]. The argument should be of type: string"