我希望为我的TradingView设置一个参考表。我的目的是比较5个股票股票,即Apple(AAPL),Microsoft(MSFT),Amazon(AMZN),Google(Googl)和Tesla(TSLA)。数据是当前的价格,价格变化(从昨天)和百分比变化。
这是表
https://prnt.sc/xzan3fjjjwuzz
我接下来要做什么是什么,根据正变化或负变化为细胞着色。因此,如果更改是正的,则细胞背景将变为绿色,如果为阴性,则变为红色。
我尝试使用有条件的逻辑,但我遇到了错误:使用了“系列颜色”类型的参数,但期望“系列int”
我搜索了此主题中的stackoverflow中只能找到两个问题:
-
- 将系列整数转换为pinescript中的整数
但是,我无法理解如何将他们的答案与我的案件联系起来。
是我用来计算值的代码段
pr_x2 = request.security(x1,"D", close[1])
pr_x1 = request.security(x1,"", close)
pr_diff = (pr_x1 - pr_x2)
pr_pct = truncate(((pr_diff1/pr_x2)*100),2)
这
pr_x2->前一天关闭
pr -x1 - >当前价值
我正在尝试将此条件用于单元格中的背景:
table.cell(panel, 0, 1, str.tostring(pr_diff) + "\nChg: " + str.tostring(pr_pct1) + " %", bgcolor = (pr_diff>0)?color.green:color.red, text_color=color.white)
但是后来我得到了上面提到的错误。
我在讨论论坛中读到,将系列整数转换为Pinescript中的整数。我的案子有解决方法吗?
I am looking to have a reference table of sorts for my tradingview set up. My aim is to compare 5 stock tickers, namely apple(AAPL), microsoft(MSFT), Amazon(AMZN), Google(GOOGL) and Tesla(TSLA). The data is current price, price change(from yesterday's) and percentage change.
Here is the screengrab of the table
https://prnt.sc/XzaN3fJjwuZz
What I am doing to do next is to color the cells based on the positive or negative changes. So if a change has been positive, the cell background becomes green, if negative, then red.
I tried using conditional logic but I am getting error: An argument of 'series color' type was used but a 'series int' is expected
I searched and could find only two questions in stackoverflow on this topic:
- pine script error- An argument of 'series string' type was used but a 'const string' is expected
- Converting series integer to integer in pinescript
However, I was not able to understand as to how to relate their answers to my case.
Here is the code snippet I am using to calculate the values:
pr_x2 = request.security(x1,"D", close[1])
pr_x1 = request.security(x1,"", close)
pr_diff = (pr_x1 - pr_x2)
pr_pct = truncate(((pr_diff1/pr_x2)*100),2)
where
pr_x2 -> previous day close
pr-x1 -> current value
I'm trying to use this condition for background in the cell:
table.cell(panel, 0, 1, str.tostring(pr_diff) + "\nChg: " + str.tostring(pr_pct1) + " %", bgcolor = (pr_diff>0)?color.green:color.red, text_color=color.white)
but then I get the error I have mentioned above.
I read in the discussions forum that converting series integer to integer in pinescript cannot be done. Is there a workaround for my case?
发布评论
评论(1)
您正在尝试在单元格上,尝试在数组上应用。
You are trying on the cell, try applying on the array.