使用松树脚本版本@4 在交易视图中交叉三个移动平均线 [英] Three moving average cross over in trading view using pine script version @4

查看:138
本文介绍了使用松树脚本版本@4 在交易视图中交叉三个移动平均线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//@version=4
study(title="MA Cross", overlay=true, resolution="")
fastMA = sma(close, 55)
medMA= sma(close, 89)
slowMA =  sma(close,233)
plot(fastMA, color = color.red)
plot(medMA, color = color.green)
plot(slowMA,color= color.black)
plot(cross(fastMA,medMA,slowMA) ? short : na, style = plot.style_cross, linewidth = 4)

我想绘制三个不同移动平均线的交叉,但我不确定使用什么函数来根据值交叉所有三个.作为功​​能只让我交叉两条移动平均线 MA..例如:50 天移动平均线应该大于 80(即显示在顶部)和 80 大于 200(即显示在 200 以上但低于 80)并让它们一次交叉

I want to plot a crossover of three different moving averages but i'm not sure what function to use in order to cross all three of them according to the value. As function only lets me crossover two moving averages MA.. Ex:50 day moving average should be greater than 80 (i.e. displayed on top) and 80 be greater than 200(i.e. above 200 but lower than 80 on display) and have them corssover at once point

推荐答案

三个不同的移动平均线在一个地方交叉是一个独特的事件.下面是一个脚本,用于检查前两条移动平均线的交叉和其他两条移动平均线的相对位置.我希望这个想法很清楚,比较两个柱上的移动平均线的值,您可以独立检查任何条件.祝你好运.

The cross of three different moving averages in one place is a unique event. Below is a script that checks the cross of the first two moving averages and the relative position of the other two moving averages. I hope the idea is clear, comparing the values of the moving averages on two bars, you can independently check any condition. Good luck.

//@version=4
study(title="MA Cross", overlay=true, resolution="")
fastMA = sma(close, 55)
medMA= sma(close, 89)
slowMA =  sma(close,233)
plot(fastMA, color = color.red)
plot(medMA, color = color.green)
plot(slowMA,color= color.black)

Cond_Cross_Dn = false
if (fastMA[1] >= medMA[1] and fastMA[0] < medMA[0]) and (medMA[0] < slowMA[0])
    Cond_Cross_Dn := true

plot(Cond_Cross_Dn ? fastMA : na, style = plot.style_cross, linewidth = 4)

这篇关于使用松树脚本版本@4 在交易视图中交叉三个移动平均线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆