简体   繁体   English

将两个指标合并为一个

[英]Combining two indicator to one

I'm trying to combine 2 indicator to one.我正在尝试将 2 个指标合并为一个。

The first one is a really simple one I made my self.第一个是我自己做的一个非常简单的。 It's 2 different ema built into one indicator.它是一个指标中内置的 2 个不同的 ema。 The second I would like to integrate is the "multi time frame EMA".第二个我想整合的是“多时间框架 EMA”。

At the end, I want my indicator to display 2 ema normally and I want a 3rd one that will be a 50 period ema displaying the h1 time frame.最后,我希望我的指标正常显示 2 个 ema,我想要第 3 个是显示 h1 时间范围的 50 个周期 ema。 For exemple: on the 15 minutes charts, I will have ema1 = ema 20, ema2 = ema 50, ema 3 = ema 50 from the 1h time frame.例如:在 15 分钟图表上,我将从 1 小时时间范围内得到 ema1 = ema 20,ema2 = ema 50,ema 3 = ema 50。

I am in my first baby step as a "pine script coder" and I didn't find how to do it by my self.作为“松树脚本编码器”,我正处于迈出的第一步,但我没有找到自己的方法。

My multiple indicator script:我的多指标脚本:

indicator('EMA', overlay=true)
ema1 = ta.ema(close, length=input(title='ema1', defval=50))
plot(ema1, title='ema1', color=#f80000)
ema2 = ta.ema(close, length=input(title='ema2', defval=200))
plot(ema2, title='ema3', color=#000000)

The one I would like to add:我想补充的是:

study("Multi Time Frame Exponential Moving Average", "MTF EMA", overlay=true)
ma_len = input(title="Length", type=integer, defval=100)
src = input(title="Source", type=source, defval=close)
ma_offset = input(title="Offset", type=integer, defval=0)
res = input(title="Resolution", type=resolution, defval="240")
htf_ma = ema(src, ma_len)
out = security(tickerid, res, htf_ma)
plot(out, color=red, offset=ma_offset) 

If you want to merge two script, make sure that they have the same pinescript version.如果要合并两个脚本,请确保它们具有相同的pinescript版本。

Your first script is written in v5 and your second script seems to be written in v1 or v2 or v3 .您的第一个脚本是用v5编写的,您的第二个脚本似乎是用v1v2v3编写的。

If you don't have a version identifier, just add //@version=3 to top of your script and either convert it to v5 manually or use the auto converter tool.如果您没有版本标识符,只需将//@version=3添加到脚本顶部,然后手动将其转换为v5或使用自动转换工具。

Use the Migration Guideline when you need support.当您需要支持时,请使用迁移指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM