首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于1小时图的5分钟图的指数移动平均值

问基于1小时图的5分钟图的指数移动平均值
EN

Stack Overflow用户
提问于 2019-09-07 03:12:12
回答 1查看 2.4K关注 0票数 0

我正在尝试写一个交易视图与松树脚本的指标。

我想写一个基于1小时图的均线,并在5分钟图中使用它。包括8和34个交易期(2个均线)。这有可能吗?

当我在5分钟图中进行交易时,我很容易看到更高的趋势。

这是我第一次尝试写代码。

不幸的是,我没有时间去学习它。

如果有人能给我一些关于如何解决这个问题的建议,那就太好了。

我试图找到一些与谷歌的指南,但只有一些关于如何编程的EMA。

我找到的所有东西都是:

//@version=3

//在pine脚本的最开始,我们总是声明我们要使用的版本,//您可以看到,上面我们使用的是pine脚本的版本3 // pine脚本中的@version单词必须在脚本的开头注释

研究(“在pinescript中编码ema”,overlay=true)

//这是我们定义研究的地方,// pinescipt中的一个研究函数用于告诉pine脚本我们将构建一个指示器//使用“overlay=true ",让pine脚本知道您想要将图表中的绘图叠加到//烛台图上。

//现在我们定义了一个EMA函数,名为pine_ema,具有两个参数x和y //此pine_ema函数的唯一目的是返回当前蜡烛收盘价pine_ema(src,time_period) =>的当前ema

代码语言:javascript
复制
alpha = 2 / (time_period + 1)
// we have defined the alpha function above
ema = 0.0
// this is the initial declaration of ema, since we dont know the first ema we will declare it to 0.0 [as a decimal]
ema := alpha * src + (1 - alpha) * nz(ema[1])
// this returns the computed ema at the current time
// notice the use of : (colon) symbol before =, it symbolises, that we are changing the value of ema,
// since the ema was previously declared to 0
// this is called mutable variale declaration in pine script
ema
// return ema from the function

_10_period_ema = pine_ema( close,10) //这里我们刚刚调用了我们的函数,src为close,time_period为10

plot( _10_period_ema,color=red,transp=30,linewidth=2) //现在我们绘制_10_period_ema

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-07 08:51:48

您可以在任何小于1小时的图表上使用此图表:

代码语言:javascript
复制
//@version=4
study("", "Emas 1H", true)
fastLength = input(8)
slowLength = input(34)
ema1hFast = security(syminfo.tickerid, "60", ema(close, fastLength))
ema1hSlow = security(syminfo.tickerid, "60", ema(close, slowLength))
plot(ema1hFast)
plot(ema1hSlow, color = color.fuchsia)

编辑2019.09.07 08:55 - LucF

代码语言:javascript
复制
//@version=4
study("", "Emas 1H", true)
fastLength  = input(8)
slowLength  = input(34)
smooth      = input(false, "Smooth")
smoothLen   = input(4, "Smoothing length", minval = 2)

ema1hFastRaw    = security(syminfo.tickerid, "60", ema(close, fastLength))
ema1hSlowRaw    = security(syminfo.tickerid, "60", ema(close, slowLength))
ema1hFastSm     = ema(ema(ema(ema1hFastRaw, smoothLen), smoothLen), smoothLen)
ema1hSlowSm     = ema(ema(ema(ema1hSlowRaw, smoothLen), smoothLen), smoothLen)
ema1hFast       = smooth ? ema1hFastSm : ema1hFastRaw
ema1hSlow       = smooth ? ema1hSlowSm : ema1hSlowRaw

plot(ema1hFast)
plot(ema1hSlow, color = color.fuchsia)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57827417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档