admin管理员组文章数量:1192366
Hi there in line 11 (for i = 0 to array.size(djia_tickers) - 1)
I am getting the error mentioned in the title. I am brand new in pine script, can someone please advise ?
indicator("DIA ETF: 25% or Fewer Stocks Below 20-Day SMA", overlay=true)
djia_tickers = "AAPL", "MSFT", "JPM", "V", "GS", "DIS", "HD", "INTC", "MCD", "BA","UNH", "KO", "WMT", "PG", "AXP", "CAT", "CVX", "IBM", "MRK", "CSCO","XOM", "COST", "PFE", "TRV", "MMM", "AMGN", "WBA", "HON", "CRM", "NKE", "DD"
sma_length = 20
stocks_below_sma = 0
for i = 0 to array.size(djia_tickers) - 1
ticker = array.get(djia_tickers, i)
sma_stock = request.security(ticker, "D", ta.sma(close, sma_length))
if close < sma_stock
stocks_below_sma := stocks_below_sma + 1
percent_below_sma = (stocks_below_sma / array.size(djia_tickers)) * 100
condition = percent_below_sma <= 25
plotshape(series=condition, location=location.belowbar, color=color.red, style=shape.labeldown, title="25% or Fewer Stocks Below 20-Day SMA", text="25% Below SMA")
barcolor(condition ? color.red : na)
Hi there in line 11 (for i = 0 to array.size(djia_tickers) - 1)
I am getting the error mentioned in the title. I am brand new in pine script, can someone please advise ?
indicator("DIA ETF: 25% or Fewer Stocks Below 20-Day SMA", overlay=true)
djia_tickers = "AAPL", "MSFT", "JPM", "V", "GS", "DIS", "HD", "INTC", "MCD", "BA","UNH", "KO", "WMT", "PG", "AXP", "CAT", "CVX", "IBM", "MRK", "CSCO","XOM", "COST", "PFE", "TRV", "MMM", "AMGN", "WBA", "HON", "CRM", "NKE", "DD"
sma_length = 20
stocks_below_sma = 0
for i = 0 to array.size(djia_tickers) - 1
ticker = array.get(djia_tickers, i)
sma_stock = request.security(ticker, "D", ta.sma(close, sma_length))
if close < sma_stock
stocks_below_sma := stocks_below_sma + 1
percent_below_sma = (stocks_below_sma / array.size(djia_tickers)) * 100
condition = percent_below_sma <= 25
plotshape(series=condition, location=location.belowbar, color=color.red, style=shape.labeldown, title="25% or Fewer Stocks Below 20-Day SMA", text="25% Below SMA")
barcolor(condition ? color.red : na)
Share
Improve this question
edited Jan 25 at 9:48
Yash Mehta
2,0063 gold badges12 silver badges21 bronze badges
asked Jan 24 at 6:00
GuzGuz
12 bronze badges
1
- Hi there in line 11 (for i = 0 to array.size(djia_tickers) - 1) I am getting the error mentioned in the title. I am brand new in pine script, can someone please advise ? Thanks – Guz Commented Jan 24 at 6:11
1 Answer
Reset to default -1indicator("DIA ETF: 25% or Fewer Stocks Below 20-Day SMA", overlay=true)
djia_tickers = array.from("AAPL", "MSFT", "JPM", "V", "GS", "DIS", "HD", "INTC", "MCD", "BA","UNH", "KO", "WMT", "PG", "AXP", "CAT", "CVX", "IBM", "MRK", "CSCO","XOM", "COST", "PFE", "TRV", "MMM", "AMGN", "WBA", "HON", "CRM", "NKE", "DD")
sma_length = 20
stocks_below_sma = 0
for i = 0 to array.size(djia_tickers) - 1
ticker = array.get(djia_tickers, i)
sma_stock = request.security(ticker, "D", ta.sma(close, sma_length))
if close < sma_stock
stocks_below_sma += 1
percent_below_sma = (stocks_below_sma / array.size(djia_tickers)) * 100
condition = percent_below_sma <= 25
plotshape(condition, location=location.belowbar, color=color.red, style=shape.labeldown, title="25% or Fewer Stocks Below 20-Day SMA", text="25% Below SMA")
barcolor(condition ? color.red : na)
版权声明:本文标题:pine script error: Incorrect 'for' statement. Expecting 'to <expression>' (line 11 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738444905a2087159.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论