OPEN-SOURCE SCRIPT

MACD 绿柱买入 红柱卖出Histogram Strategy

95
逻辑解释:
1.买入条件:

当 MACD 的 Histogram 从负转正(由红柱变为绿柱)时,触发 strategy.entry('MACD_Buy', strategy.long),执行买入操作。

2.卖出条件:

当 MACD 的 Histogram 从正转负(由绿柱变为红柱)时,触发 strategy.close('MACD_Buy'),执行卖出操作。

3.绘图保持不变:

绿柱和红柱都正常显示,MACD 和信号线也正常绘制。

本策略仅供学习与参考,不构成投资建议
您不应该使用此策略进行真实交易,任何情况下使用此策略造成的损失本人概不负责

Logic Explanation:

Buy Condition:
When the MACD Histogram turns from negative to positive (from red bars to green bars), it triggers strategy.entry('MACD_Buy', strategy.long), executing a buy operation.

Sell Condition:
When the MACD Histogram turns from positive to negative (from green bars to red bars), it triggers strategy.close('MACD_Buy'), executing a sell operation.

Plotting remains unchanged:
Green and red bars are displayed correctly, and both the MACD and signal lines are plotted as usual.

Disclaimer:
This strategy is for educational and reference purposes only.
You should not use this strategy for real trading, and I am not responsible for any losses incurred from using this strategy under any circumstances.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.