用提醒自动化 EMA 金叉与死叉信号
文章 OctoBot
总结
本教程展示如何将 TradingView 提醒与 OctoBot 自动化功能配合,自动执行移动平均线交叉策略。短期指数移动平均线向上穿越长期均线时产生买入信号;向下穿越时产生卖出信号。示例使用 BTC/USDT、5 分钟图表,以及长度为 9 和 21 的 EMA,同时指出,通常较长的时间周期可能更适合这种方法。
工作流配置一个买入自动化和一个卖出自动化,再将它们关联到每根 K 线收盘时触发一次的提醒。在示例中,买入使用一半 USDT 余额,卖出则通过市价单平掉 BTC 余额。教程提供了设置说明和图示,但没有回测、表现数据、交易成本分析或风险控制措施。结果取决于所选市场、时间周期、EMA 设置、执行方式和提醒可靠性;文档将该策略作为教学示例,而非盈利证据。
核心观点
- 短期 EMA 向上穿越长期 EMA 时形成金叉,向下交叉则形成死叉。
- 示例在 5 分钟 BTC/USDT 图表上使用长度为 9 和 21 的 EMA。
- 设置为 K 线收盘时触发的 TradingView 提醒,会触发对应的 OctoBot 买入和卖出自动化。
- 示例使用一半 USDT 余额买入,并通过市价单卖出全部 BTC。
- 教程没有提供盈利证据或回测结果。
标签
全文
# Automating a TradingView Death and Golden Cross Strategy --- title: "Golden Cross Strategy" description: "Learn to automate a Bitcoin Death and Golden Cross Strategy using TradingView alerts and OctoBot with paper or real trading on any exchange." sidebar_position: 2 --- # Automating a TradingView Death and Golden Cross Strategy With this tutorial, you will learn how to trade with Death and Golden Crosses using two <a href="https://www.investopedia.com/terms/e/ema.asp" rel="nofollow">Exponential Moving Averages</a> (or EMA). The concept is to: - Buy when the short term EMA crosses up the long term EMA. This is a <a href="https://www.investopedia.com/terms/g/goldencross.asp" rel="nofollow">Golden Cross</a> and is usually a bullish sign. - Sell when the short term EMA crosses down the long term EMA. This is a <a href="https://www.investopedia.com/terms/d/deathcross.asp" rel="nofollow">Death Cross</a> and is usually a bearish sign. ## 1. Automatically identifying Death and Golden Crosses ### 1.1 Select your traded market First, we want to visually see our Death and Golden Crosses. Let's go to <a href="https://www.tradingview.com/?aff_id=27595" rel="nofollow">TradingView</a> and select the trading pair, exchange and time frame we want to trade. <div style="text-align: center">  </div> For this tutorial, we will trade BTC/USDT on Binance using the 5 minutes time frame. Of course, any other value would also work. Note: Trading on Death and Golden Crosses is usually more profitable on longer time frames. In this tutorial the 5 minutes time frame is only meant as an example. ### 1.2 Add the EMA indicators Then we will add the Exponential Moving Average indicator twice: 1. Once for the long term EMA 2. Once for the short term EMA <div style="text-align: center">  </div> ### 1.3 Configure the EMA indicators Click on the `Settings` of both of your EMA indicators and set the `Length` value according to how you wish to configure your Death and Golden Crosses. <div style="text-align: center">  </div> In this example, we will use the following values: 1. `21` for the Length of the long term EMA 2. `9` for the Length of the short term EMA Note: you can also configure the `Style` of those EMA to make them easier to visualize on the chart ### 1.4 Visualize the Strategy Death and Golden crosses happen when the long and short term EMA are crossing. We can now easily see what it would look like. <div style="text-align: center">  </div> Our strategy is ready, the only remaining step is to create an OctoBot to trade when those crosses happen. ## 2. Creating OctoBot automations to buy and sell ### 2.1 Create a TradingView OctoBot Let's open a new tab and go to <a href="https://www.octobot.cloud/dashboard" rel="nofollow">OctoBot cloud</a> to start a new TradingView OctoBot <div style="text-align: center">  </div> **[Start a bot](https://www.octobot.cloud)** For this tutorial, we will start a bot on Binance. If you are unsure about how to start a TradingView OctoBot, check out the `Create your TradingView OctoBot` section of the [TradingView trading tutorial](../tradingview-trading-tutorial#1-create-your-tradingview-octobot). ### 2.2 Create your BUY automation When a Golden Cross happens, we want our OctoBot to buy. For this tutorial, we will buy using 50% of our portfolio's USDT holdings. <div style="text-align: center">  </div> ### 2.3 Create your SELL automation When a Death Cross occurs, we want our OctoBot to sell. For this tutorial, we will sell all of our portfolio's BTC holdings. <div style="text-align: center">  </div> Note: in this tutorial, we are keeping things simple by using market orders, selling everything at once and having only one type of BUY and SELL automation. Since there is no limit the the automations you can create, you customize this strategy as much as you want by creating other BUY and SELL automations. ## 3. Binding automations to trigger on Crosses Note: the following steps are assuming that you already configured your TradingView Alerts webhook URL. If it is not the case, please follow the [Configure the webhook URL guide](../tradingview-trading-tutorial#25-configure-the-webhook-url). ### 3.1 Buying on Golden Crosses Open the connection panel of your BUY automation and copy its automation identifier. <div style="text-align: center">  </div> <div style="text-align: center">  </div> Going back to your TradingView tab, create a new alert <div style="text-align: center">  </div> <div style="text-align: center">  </div> In this alert, pay attention to: - Select `Crossing Up` as wall as EMA 9 and 21 as Condition: this is our Golden Cross. - Select `Once Per Bar Close` as Trigger to check for Golden Crosses on each candle close. - Give a meaningful name to your alert to easily identify it later on. - Replace the full Message value by your BUY automation identifier from the OctoBot tab. Great ! Your TradingView strategy will not send an alert triggering your OctoBot BUY automation when a Golden Cross is identified according to your EMA settings. ### 3.2 Selling on Death Crosses Similarly to the Golden Cross configuration: 1. On your OctoBot tab, open your SELL automation connection panel. 2. On the TradingView tab, create a seconds alert to identify Death Crosses and configure it to trigger your SELL automation. <div style="text-align: center">  </div> In this alert, remember to: - Select `Crossing Down` as wall as EMA 9 and 21 as Condition: this is our Death Cross. - Select `Once Per Bar Close` as Trigger to check for Death Crosses on each candle close. - Give a meaningful name to your alert to easily identify it later on. - Replace the full Message value by your SELL automation identifier from the OctoBot tab. ## The strategy is ready And that's it ! We just created an EMA Death and Golden Cross strategy on TradingView and automated its trading using OctoBot. Everytime a Death or Golden cross happen on TradingView, our OctoBot will buy or sell BTC accordingly.   Of course, you can use this configuration to trade any pair(s) on any exchange using your real funds or risk free with [simulated funds](../paper-trading-a-strategy). **[Start your TradingView OctoBot](https://www.octobot.cloud)** We hope this tutorial was clear enough. Please let is know if there is something we should improve. :::info Warning: The strategy presented in this tutorial is only meant for educational purposes and is not financial advice. :::
在遵守原作品许可的前提下,附作者信息全文展示。 许可协议: GPL-3.0
此摘要由 Stratmill 研究智能体根据原文撰写,并非原文副本。