简体   繁体   English

如何在 pine-script TradingView 中开发基于“直方图颜色变化”的策略

[英]How to develop a "Histogram Color Change" based strategy in pine-script TradingView

I am using MACD-Histogram as one of the main technical analysis tool for some times now.我使用 MACD-Histogram 作为主要技术分析工具之一已经有一段时间了。 In my experience the the zero-line crossover of histogram along with histogram color change and its fading or saturating all are profitable trading signals with high degree of accuracy on higher time frame particularly.根据我的经验,直方图的零线交叉以及直方图颜色的变化及其褪色或饱和都是有利可图的交易信号,尤其是在更高的时间范围内具有高度的准确性。

The zero-line crossover strategy is available by default in TradingView. TradingView 中默认提供零线交叉策略。 Now I want to write a strategy based on change in histogram color, color fading and saturating.现在我想写一个基于直方图颜色变化、褪色和饱和度的策略。 Which functions and arguments should I be using in Pine-script?我应该在 Pine-script 中使用哪些函数和 arguments? Please help.请帮忙。 Thanks for your time, Regards.谢谢你的时间,问候。

Well, you have access to how histogram color is calculated.好吧,您可以访问如何计算直方图颜色。

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)))

So, you need to break it down to something like that:所以,你需要把它分解成这样的东西:

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)

Then compare them with their previous values to see if there is a color change:然后将它们与之前的值进行比较,看看是否有颜色变化:

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

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

相关问题 如何使用 pine-script 在 TradingView 中编写多时间框架策略? - How to code a multiple timeframe strategy in TradingView with pine-script? 如何将指标调用到我的策略中 (Pine-Script) (Tradingview) - How to call indicators into my strategy (Pine-Script) (Tradingview) Pine-Script Tradingview 策略中的条件激活警报 - Conditionally Activated Alert In Pine-Script Tradingview Strategy Pine脚本如何在RSI图上发送颜色变化警报 - Pine-script how to send alert on color change on RSI graph 如何从 Tradingview 解锁锁定的 pine 脚本 - How to unlock a locked pine-script from Tradingview 如何在 TradingView Pine-Script 中运行条件语句? - How to Run a Conditional Statement in TradingView Pine-Script? 如何在 pine-script TradingView 中按升序对 20 个变量进行排序? - How to sort in ascending order 20 variables, in pine-script, TradingView? Tradingview Pine-Script:如何仅绘制最后 x 个周期 - Tradingview Pine-Script: How to plot only the last x periods 如何在tradingview上添加图像水印松脚本 - How to add image watermark pine-script on tradingview 在 tradingview pine-script 策略中,我设置了止盈和止损,但它不能正常工作 - In the tradingview pine-script strategy, I set a takeprofit and stoploss but it doesn't work properly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM