Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pine script Pinescript-EMA cross&;随机交叉_Pine Script - Fatal编程技术网

Pine script Pinescript-EMA cross&;随机交叉

Pine script Pinescript-EMA cross&;随机交叉,pine-script,Pine Script,我试图在9个均线穿过20个均线时用Pinescript编写一些代码,以显示长期策略。相反,我想展示当20均线穿过9均线时的空头策略。这对我来说似乎很管用 我遇到的问题是,当随机RSI显示为多头时,显示为第二个多头策略,但我只希望当9个均线穿过20个均线时,该陈述为真 这是我的密码: //@version=2 strategy("Isaac Signals2", overlay=true) //ema ema3 = ema(close,9) ema4 = ema(close,20) lo

我试图在9个均线穿过20个均线时用Pinescript编写一些代码,以显示长期策略。相反,我想展示当20均线穿过9均线时的空头策略。这对我来说似乎很管用

我遇到的问题是,当随机RSI显示为多头时,显示为第二个多头策略,但我只希望当9个均线穿过20个均线时,该陈述为真

这是我的密码:

    //@version=2
strategy("Isaac Signals2", overlay=true)

//ema
ema3 = ema(close,9)
ema4 = ema(close,20)
long_ema = crossover(ema3,ema4)
short_ema = crossover(ema4,ema3)

//stochrsi
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src = input(close, title="RSI Source")

rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)

data = (60-k[1])/2
data2 = (k[1]-40)/2

long_stoch = k[1] >= d[1] and k[2] <= d[2] and k <= 60 and k >= 10
short_stoch = k[1] <= d[1] and k[2] >= d[2] and k >= 40 and k <= 95

//entries
if (long_ema) 
    strategy.entry("buy", strategy.long)
**if (long_ema and long_stoch)
    strategy.entry("buy+1", strategy.long)**
if (short_ema) 
    strategy.entry("sell", strategy.short)
/@version=2
策略(“Isaac信号2”,叠加=真)
//均线
ema3=ema(关闭,9)
ema4=ema(关闭,20)
long_ema=交叉(ema3、ema4)
短ema=交叉(ema4、ema3)
//斯托赫西
smoothK=输入(3,最小值=1)
smoothD=输入(3,最小值=1)
长度RSI=输入(14,最小值=1)
lengthStoch=输入(14,最小值=1)
src=输入(关闭,title=“RSI源”)
rsi1=rsi(src,长度rsi)
k=sma(stoch(rsi1,rsi1,rsi1,长度stoch),smoothK)
d=sma(k,平滑d)
数据=(60-k[1])/2
数据2=(k[1]-40)/2
long_stoch=k[1]>=d[1]和k[2]=40和k这可能会有所帮助

//@version=2
strategy("Isaac Signals2", overlay=true)

//ema
ema3 = ema(close,9)
ema4 = ema(close,20)
long_ema = crossover(ema3,ema4)
short_ema = crossover(ema4,ema3)

//stochrsi
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src = input(close, title="RSI Source")

rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)

data = (60-k[1])/2
data2 = (k[1]-40)/2

long_stoch = k[1] >= d[1] and k[2] <= d[2] and k <= 60 and k >= 10
short_stoch = k[1] <= d[1] and k[2] >= d[2] and k >= 40 and k <= 95

//entries
if (long_ema) 
    strategy.entry("buy", strategy.long)
if (ema3 > ema4 and long_stoch) // ema3 > ema4 means that crossover was already and uptrend is continuing 
    strategy.entry("buy+1", strategy.long)
if (short_ema) 
    strategy.entry("sell", strategy.short)
/@version=2
策略(“Isaac信号2”,叠加=真)
//均线
ema3=ema(关闭,9)
ema4=ema(关闭,20)
long_ema=交叉(ema3、ema4)
短ema=交叉(ema4、ema3)
//斯托赫西
smoothK=输入(3,最小值=1)
smoothD=输入(3,最小值=1)
长度RSI=输入(14,最小值=1)
lengthStoch=输入(14,最小值=1)
src=输入(关闭,title=“RSI源”)
rsi1=rsi(src,长度rsi)
k=sma(stoch(rsi1,rsi1,rsi1,长度stoch),smoothK)
d=sma(k,平滑d)
数据=(60-k[1])/2
数据2=(k[1]-40)/2
long_stoch=k[1]>=d[1]和k[2]=40,k ema4和long_stoch)//ema3>ema4意味着交叉已经发生,上升趋势正在继续
strategy.entry(“买入+1”,strategy.long)
如果(短时间)
策略.输入(“卖出”,策略.空头)
这可能会有所帮助

//@version=2
strategy("Isaac Signals2", overlay=true)

//ema
ema3 = ema(close,9)
ema4 = ema(close,20)
long_ema = crossover(ema3,ema4)
short_ema = crossover(ema4,ema3)

//stochrsi
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src = input(close, title="RSI Source")

rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)

data = (60-k[1])/2
data2 = (k[1]-40)/2

long_stoch = k[1] >= d[1] and k[2] <= d[2] and k <= 60 and k >= 10
short_stoch = k[1] <= d[1] and k[2] >= d[2] and k >= 40 and k <= 95

//entries
if (long_ema) 
    strategy.entry("buy", strategy.long)
if (ema3 > ema4 and long_stoch) // ema3 > ema4 means that crossover was already and uptrend is continuing 
    strategy.entry("buy+1", strategy.long)
if (short_ema) 
    strategy.entry("sell", strategy.short)
/@version=2
策略(“Isaac信号2”,叠加=真)
//均线
ema3=ema(关闭,9)
ema4=ema(关闭,20)
long_ema=交叉(ema3、ema4)
短ema=交叉(ema4、ema3)
//斯托赫西
smoothK=输入(3,最小值=1)
smoothD=输入(3,最小值=1)
长度RSI=输入(14,最小值=1)
lengthStoch=输入(14,最小值=1)
src=输入(关闭,title=“RSI源”)
rsi1=rsi(src,长度rsi)
k=sma(stoch(rsi1,rsi1,rsi1,长度stoch),smoothK)
d=sma(k,平滑d)
数据=(60-k[1])/2
数据2=(k[1]-40)/2
long_stoch=k[1]>=d[1]和k[2]=40,k ema4和long_stoch)//ema3>ema4意味着交叉已经发生,上升趋势正在继续
strategy.entry(“买入+1”,strategy.long)
如果(短时间)
策略.输入(“卖出”,策略.空头)

谢谢!这很接近我想要的。我想显示第一个长信号(第一个if语句),然后当随机RSI在ema交叉后长时间显示时,显示第二个或第三个长信号。这并不能完全做到这一点,但已经很接近了。我建议你更清楚、更明确地制定进入多头仓位的规则。也许你想把你的多头仓位金字塔化?没错!我不是松树体诗。我不知道你能做到。我怎样才能做到这一点呢?策略(“Isaac Signals2”,overlay=true,pyraming=10)非常感谢。这正是我一直想要的。非常感谢。谢谢这很接近我想要的。我想显示第一个长信号(第一个if语句),然后当随机RSI在ema交叉后长时间显示时,显示第二个或第三个长信号。这并不能完全做到这一点,但已经很接近了。我建议你更清楚、更明确地制定进入多头仓位的规则。也许你想把你的多头仓位金字塔化?没错!我不是松树体诗。我不知道你能做到。我怎样才能做到这一点呢?策略(“Isaac Signals2”,overlay=true,pyraming=10)非常感谢。这正是我一直想要的。非常感谢。