不支持 Pinescript 错误版本
Pinescript error version is not supported
我有下面的代码,这是一个简单的策略,我设法做到了,谁能解决这个问题?
在我向它添加时间和 ADX 部分之前它工作正常
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CristianPita
//@version=6
strategy("SG", overlay=true)
/////SMMA
len = input(30, minval=1, title="Length")
src = input(close, title="Source")
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len
plot(smma, color=color.red)
////EMA
len1 = input(9, minval=1, title="Length")
src1 = input(close, title="Source")
offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
out = ema(src1, len1)
plot(out, title="EMA", color=color.blue, offset=offset)
////////////////TIME
t = time(timeframe.period, "0800-2000")
time_cond = not na(t)
/////////////ADX
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
/////////////
longCondition = (out > smma ) and (close > out)
if(longCondition and time_cond and sig>20)
strategy.entry("Longo", long=true, qty= 50000)
strategy.exit("Exit", "Longo", qty=50000, when = open < smma )
shortCondiiton = (out < smma) and ( close < out)
if(shortCondiiton and time_cond and sig>20)
strategy.entry("Shorto", long=false, qty= 50000)
strategy.exit("Exit", "Shorto", qty= 50000, when = open > smma)
没有版本 6 伴侣。
//@version=6
尝试改变这个
对此:
//@version=5
您可能认为这一行是注释,但 pinescript 会读取它!
但是我注意到当您更改为 5 时仍然会出现很多错误,因此我尝试更正一些错误,但是它不会给出长信号或短信号。但它正在添加到图表中也许比我更了解的人可以修复它
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CristianPita
//@version=5
strategy("SG", overlay=true)
/////SMMA
len = input.int(30, minval=1, title="Length")
src = close
smma = 0.0
smma := na(ta.sma(close,1)) ? ta.sma(src,len) : (ta.sma(close,1) * (len - 1) + src) / len
plot(smma, color=color.red)
////EMA
len1 = input.int(9, minval=1, title="Length")
src1 = close
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out = ta.ema(src1, len1)
plot(out, title="EMA", color=color.blue, offset=offset)
////////////////TIME
t = time(timeframe.period, "0800-2000")
time_cond = not na(t)
/////////////ADX
adxlen = input.int(14, title="ADX Smoothing")
dilen = input.int(14, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
/////////////
longCondition = (out > smma ) and (close > out)
if(longCondition and time_cond and sig>20)
strategy.entry("Long", strategy.long, qty= 50000)
strategy.close("Exit", qty=50000, when = open < smma )
shortCondiiton = (out < smma) and ( close < out)
if(shortCondiiton and time_cond and sig>20)
strategy.entry("Short", strategy.short, qty= 50000)
strategy.close("Exit", qty= 50000, when = open > smma)
我有下面的代码,这是一个简单的策略,我设法做到了,谁能解决这个问题? 在我向它添加时间和 ADX 部分之前它工作正常
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CristianPita
//@version=6
strategy("SG", overlay=true)
/////SMMA
len = input(30, minval=1, title="Length")
src = input(close, title="Source")
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len
plot(smma, color=color.red)
////EMA
len1 = input(9, minval=1, title="Length")
src1 = input(close, title="Source")
offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
out = ema(src1, len1)
plot(out, title="EMA", color=color.blue, offset=offset)
////////////////TIME
t = time(timeframe.period, "0800-2000")
time_cond = not na(t)
/////////////ADX
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
/////////////
longCondition = (out > smma ) and (close > out)
if(longCondition and time_cond and sig>20)
strategy.entry("Longo", long=true, qty= 50000)
strategy.exit("Exit", "Longo", qty=50000, when = open < smma )
shortCondiiton = (out < smma) and ( close < out)
if(shortCondiiton and time_cond and sig>20)
strategy.entry("Shorto", long=false, qty= 50000)
strategy.exit("Exit", "Shorto", qty= 50000, when = open > smma)
没有版本 6 伴侣。
//@version=6
尝试改变这个
对此:
//@version=5
您可能认为这一行是注释,但 pinescript 会读取它!
但是我注意到当您更改为 5 时仍然会出现很多错误,因此我尝试更正一些错误,但是它不会给出长信号或短信号。但它正在添加到图表中也许比我更了解的人可以修复它
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CristianPita
//@version=5
strategy("SG", overlay=true)
/////SMMA
len = input.int(30, minval=1, title="Length")
src = close
smma = 0.0
smma := na(ta.sma(close,1)) ? ta.sma(src,len) : (ta.sma(close,1) * (len - 1) + src) / len
plot(smma, color=color.red)
////EMA
len1 = input.int(9, minval=1, title="Length")
src1 = close
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out = ta.ema(src1, len1)
plot(out, title="EMA", color=color.blue, offset=offset)
////////////////TIME
t = time(timeframe.period, "0800-2000")
time_cond = not na(t)
/////////////ADX
adxlen = input.int(14, title="ADX Smoothing")
dilen = input.int(14, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
/////////////
longCondition = (out > smma ) and (close > out)
if(longCondition and time_cond and sig>20)
strategy.entry("Long", strategy.long, qty= 50000)
strategy.close("Exit", qty=50000, when = open < smma )
shortCondiiton = (out < smma) and ( close < out)
if(shortCondiiton and time_cond and sig>20)
strategy.entry("Short", strategy.short, qty= 50000)
strategy.close("Exit", qty= 50000, when = open > smma)