我对 Pine 比较陌生,一般来说我在编程方面是自学的,但我知道一些基础知识..
我正在尝试学习 pine,并通过编写这些相当基本的设置来挑战自己,这样我就可以看到并希望更好地了解正在发生的事情。
现在我尝试将此代码复制到molde round,看看如果我改变X或Y会发生什么,并注意到一些我无法解释的奇怪东西
因此,除了输入的日期与烛台上显示的日期不匹配之外,代码本身似乎还可以工作... 我已经尝试将我的观点更改为 UTC 和 Exchange,因为我读到它可能会产生影响(通常我是 UTC+1),我的目标是让它接受这一点。但我要强调的是,它根本不会改变任何东西。是的,我曾尝试将其删除并在 UTC 更改后重新插入
Picture of that shows the confusion
有什么可以帮助澄清为什么它全部转移 1 天的吗?! 难道只是图形错误??
//@version=4
strategy(title="Backtest since certain date", overlay=true)
// STEP 1:
// Configure backtest start date with inputs
startDate = input(title="Start Date", type=input.integer,
defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", type=input.integer,
defval=1, minval=1, maxval=12)
startYear = input(title="Start Year", type=input.integer,
defval=2021, minval=1800, maxval=2100)
// STEP 2:
// See if this bar's time happened on/after start date
afterStartDate = (time >= timestamp(syminfo.timezone,
startYear, startMonth, startDate, 0, 0))
// Calculate strategy values
emaValue = ema(close, 20)
plot(series=emaValue, color=color.teal, linewidth=2)
// Set trade entry conditions
enterLong = (close > close[1]) and crossover(close, emaValue)
enterShort = (close < close[1]) and crossunder(close, emaValue)
// STEP 3:
// Submit entry orders, but only on/after start date
if (afterStartDate and enterLong)
strategy.entry(id="EL", long=true)
if (afterStartDate and enterShort)
strategy.entry(id="ES", long=false)