【问题标题】:How to develop a "Histogram Color Change" based strategy in pine-script TradingView如何在 pine-script TradingView 中开发基于“直方图颜色变化”的策略
【发布时间】:2022-11-30 05:46:41
【问题描述】:

一段时间以来,我一直在使用 MACD-Histogram 作为主要的技术分析工具之一。以我的经验,直方图的零线交叉以及直方图颜色变化及其褪色或饱和都是有利可图的交易信号,尤其是在较高时间范围内具有高精度。

零线交叉策略在 TradingView 中默认可用。现在我想写一个基于直方图颜色变化、颜色褪色和饱和度的策略。我应该在 Pine-script 中使用哪些函数和参数?请帮忙。谢谢你的时间, 问候。

【问题讨论】:

    标签: pine-script


    【解决方案1】:

    好吧,您可以了解直方图颜色是如何计算的。

    plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
    

    所以,你需要把它分解成这样的东西:

    is_grow_above = (hist>=0) and (hist[1] < hist)
    is_fall_above = (hist>=0) and not (hist[1] < hist)
    is_grow_below = not (hist>=0) and (hist[1] < hist)
    is_fall_below = not (hist>=0) and not (hist[1] < hist)
    

    然后将它们与之前的值进行比较,看看是否有颜色变化:

    is_new_grow_above = not is_grow_above[1] and is_grow_above
    is_new_fall_above = not is_fall_above[1] and is_fall_above
    is_new_grow_below = not is_grow_below[1] and is_grow_below
    is_new_fall_below = not is_fall_below[1] and is_fall_below
    

    【讨论】:

    • 简直太棒了!
    • 交易信号如下 - 当“Color Fall Below”时入场多头,当“Color Fall Above”时入场空头。如何将这些信号绘制为叠加在条形图下方和上方?
    【解决方案2】:

    我对 pinescripting 非常陌生,一直在尝试寻找一种方法来创建类似于上述的警报:

    • 当 macd 直方图从红色变为绿色(或从红色变为粉色)时买入信号/警报
    • MACD 直方图从绿色变为红色(或从深绿色变为浅绿色)时卖出信号/警报

    我试图在 Krishnendu 之上实现你的代码,但作为一个新手,我失败得很惨......

    你能帮忙吗!

    【讨论】:

    • @krishnenduBhattacharyya
    猜你喜欢
    • 2020-01-28
    • 1970-01-01
    • 2021-09-22
    • 1970-01-01
    • 1970-01-01
    • 2023-02-06
    • 1970-01-01
    • 1970-01-01
    • 2022-12-03
    相关资源
    最近更新 更多