【发布时间】:2021-10-25 12:20:00
【问题描述】:
//@version=4 在“for 循环”代码段 "for i = index_cross to 50"(第 22 - 24 行)中,我正在寻找 rsi[i] < oversold 值。我有“max_bars_back=50”,但脚本一直给我指示错误:Pine cannot determine the referencing lenght of a series. Try using max_bars_back in the study or strategy function.
1 study("error max bars back", overlay=false, max_bars_back=50)
2
3 //input
4 oversold = input(30, title="oversold")
5 rsiLen = input(14, title="rsi len")
6
7 //rsi and ema
8 rsi = rsi(close, rsiLen)
9 ema1 = ema(close, 21)
10 ema2 = ema(close,50)
11
12 //condition 1
13 cross=crossover(ema1, ema2)
14
15 //index of condition (used in the for loop)
16 index_cross = 0
17 if cross
18 index_cross := bar_index
19
20 //condition 2
21 bool rsi_valid = false
22 for i = index_cross to 50
23 if rsi[i] < oversold
24 rsi_valid := true
25
26 //final condition and plot
27 a = rsi_valid == true ? 1 : 0
28 plot(a, color=color.white)
我使用此脚本的目标是确定“从交叉到 50 柱之前”rsi 是否小于 30(超卖)。 感谢您的支持。
【问题讨论】:
标签: pine-script