Mastering the MACD divergence signal makes your automated trading script smarter.

CN
AiCoin
Follow
1 year ago

On the evening of March 12th, AICoin researchers conducted a live graphic and text sharing session on AICoin PC-end Group Chat Live, revealing the "Automatic Trading Script for MACD Divergence Signals." Here is a summary of the live content.

I. AICoin Tool Sharing

  1. Flash News - View the calendar of major events, such as the release time of CPI.

    Flash News

  2. You can use the unique intelligent analysis of PRO version K-line to analyze the market of the currency: 1-hour BTC.

    PRO version K-line analysis

    PRO version K-line analysis

    Xiao A is the industry's first intelligent analysis robot for currencies and K-line charts launched by AICoin. Xiao A can help you in 3 minutes to: (1) analyze the trend of the currency; (2) analyze the trend of the K-line chart; (3) analyze the price trend combined with indicators; (4) provide advice on buying and selling points; (5) predict the rise and fall of the currency price. Experience the intelligent analysis of Xiao A by opening the PRO version K-line: https://aicoin.app/zh-CN/vip

  3. AI Grid Trading

    Research Institute trading test results

    AI Grid Trading

    AI grid tool: Basically, buy at the low point and sell at the high point.

    AI Grid Tool

    AI grid tool, the setting of upper and lower limits can refer to:

    Xiao A's intelligent analysis of price fluctuations;

    Use the grid tool to conduct grid trading within this price fluctuation range.

    AI Grid Tool

II. Sharing of MACD Divergence Signal Automatic Trading Script

  1. Conclusion of MACD Top and Bottom Divergence

    Conclusion: Top divergence indicates a bearish outlook; bottom divergence indicates a bullish outlook.

  2. The most core algorithm of divergence, using this function, can achieve the divergence judgment of MACD.

   func_invisible_divergence(open_, high_, low_, close_) {
       // Define indicator-related parameters
       N1 = 12
       N2 = 26
       M = 9
       // Calculate the value of the MACD indicator
       dif = ema(close_, N1) - ema(close_, N2)
       dea = ema(dif, M)
       macd = (dif - dea) * 2
       // Calculate the new high of the price
       priceNewHigh = high_ > highest(high_, 10)[1] // Assuming we use the highest price of the past 10 candles as a reference
       priceNewLow = low_ < lowest(low_, 10)[1]
       // Calculate the shortening of the MACD column
       macdShortening = macd < macd[1] and macd[1] > macd[2]
       // Calculate the lengthening of the MACD column
       macdLongening = macd > macd[1] and macd[1] < macd[2]
       // Define hidden top divergence signals
       bearishDivergence = priceNewHigh and macdShortening
       bullishDivergence = priceNewLow and macdLongening
       rets = [bullishDivergence, bearishDivergence]
       return rets
   }
  1. Specific settings of the indicator script for BTC 4-hour divergence

    Step 1: Find the custom indicator

    Custom Indicator

    Start a new script and put the core divergence indicator implementation algorithm in it

    New Script

    Step 2: The core code we use calls the 4-hour data

   // Calculate the divergence situation of the 4-hour period
   rets_4h = security(syminfo.tickerid, '4h', func_invisible_divergence(open, high, low, close))
   inv_div_4h = rets_4h{0}
   inv_div1_4h = rets_4h{1}

Step 3: We draw it on the main chart

   // Draw the signal
   plotText(inv_div_4h, title='4h Bottom Divergence Warning', text = '4h Bottom Divergence', refSeries = low, color='green', fontSize=14, placement='bottom' ,display=true);
   plotText(inv_div1_4h, title='4h Top Divergence Warning', text = '4h Top Divergence', refSeries = high, color='red', fontSize=14, placement='top' ,display=true);

Step 4: We set the alert conditions

   // Define alert conditions
   alertcondition(inv_div_4h, title='4h Bottom Divergence Warning', direction="buy")
   alertcondition(inv_div1_4h, title='4h Top Divergence Warning', direction="sell")

Step 5: Display effect on the K-line

K-line Display

You can switch to the 4-hour period for more signals

4-hour Period

Step 6: Complete code

   // This indicator is created by AICOIN Research Institute. If you encounter any usage issues, you can join the indicator community for consultation
   // @version=2
   // Define indicator-related parameters
   N1 = 12
   N2 = 26
   M = 9
   func_invisible_divergence(open_, high_, low_, close_) {
       // Define indicator-related parameters
       N1 = 12
   }

N2 = 26

M = 9

// Calculate the value of the MACD indicator

dif = ema(close, N1) - ema(close, N2)

dea = ema(dif, M)

macd = (dif - dea) * 2

// Calculate the new high of the price

priceNewHigh = high_ > highest(high_, 10)[1] // Assuming we use the highest price of the past 10 candles as a reference

priceNewLow = low_ < lowest(low_, 10)[1]

// Calculate MACD column shortening

macdShortening = macd < macd[1] and macd[1] > macd[2]

// Calculate MACD column lengthening

macdLongening = macd > macd[1] and macd[1] < macd[2]

// Define hidden top divergence signals

bearishDivergence = priceNewHigh and macdShortening

bullishDivergence = priceNewLow and macdLongening

rets = [bullishDivergence, bearishDivergence];

return rets

}

// Calculate the divergence situation of the 4-hour period

rets4h = security(syminfo.tickerid, '4h', funcinvisible_divergence(open, high, low, close))

invdiv4h = rets_4h{0}

invdiv14h = rets_4h{1}

// Draw the signal

plotText(invdiv4h, title='4h Bottom Divergence Warning', text = '4h Bottom Divergence', refSeries = low, color='green', fontSize=14, placement='bottom' ,display=true);

plotText(invdiv14h, title='4h Top Divergence Warning', text = '4h Top Divergence', refSeries = high, color='red', fontSize=14, placement='top' ,display=true);

// Define alert conditions

alertcondition(invdiv4h, title='4h Bottom Divergence Warning', direction="buy")

alertcondition(invdiv14h, title='4h Top Divergence Warning', direction="sell")

Step 7, you can pay attention to setting the main chart display

III. Adding MACD Divergence Signals for Other Periods

1. You can refer to the 4-hour divergence and modify the relevant parameters for the 1-hour divergence

See the display effect of the 1-hour divergence

Sharing the code for 1-hour and 4-hour together

// This indicator is created by AICOIN Research Institute. If you encounter any usage issues, you can join the indicator community for consultation

// @version=2

// Define indicator-related parameters

N1 = 12

N2 = 26

M = 9

funcinvisibledivergence(open, high, low, close) {

// Define indicator-related parameters

N1 = 12

N2 = 26

M = 9

// Calculate the value of the MACD indicator

dif = ema(close, N1) - ema(close, N2)

dea = ema(dif, M)

macd = (dif - dea) * 2

// Calculate the new high of the price

priceNewHigh = high_ > highest(high_, 10)[1] // Assuming we use the highest price of the past 10 candles as a reference

priceNewLow = low_ < lowest(low_, 10)[1]

// Calculate MACD column shortening

macdShortening = macd < macd[1] and macd[1] > macd[2]

// Calculate MACD column lengthening

macdLongening = macd > macd[1] and macd[1] < macd[2]

// Define hidden top divergence signals

bearishDivergence = priceNewHigh and macdShortening

bullishDivergence = priceNewLow and macdLongening

rets = [bullishDivergence, bearishDivergence];

return rets

}

// Calculate the divergence situation of the 4-hour period

rets4h = security(syminfo.tickerid, '4h', funcinvisible_divergence(open, high, low, close))

invdiv4h = rets_4h{0}

invdiv14h = rets_4h{1}

// Draw the signal

plotText(invdiv4h, title='4h Bottom Divergence Warning', text = '4h Bottom Divergence', refSeries = low, color='green', fontSize=14, placement='bottom' ,display=true);

plotText(invdiv14h, title='4h Top Divergence Warning', text = '4h Top Divergence', refSeries = high, color='red', fontSize=14, placement='top' ,display=true);

// Define alert conditions

alertcondition(invdiv4h, title='4h Bottom Divergence Warning', direction="buy")

alertcondition(invdiv14h, title='4h Top Divergence Warning', direction="sell")

// Implement the divergence for 1 hour here

rets1h = security(syminfo.tickerid, '1h', funcinvisible_divergence(open, high, low, close))

invdiv1h = rets_1h{0}

invdiv11h = rets_1h{1}

// Draw the signal

plotText(invdiv1h, title='1h Bottom Divergence Warning', text = '1h Bottom Divergence', refSeries = low, color='green', fontSize=14, placement='bottom' ,display=true);

plotText(invdiv11h, title='1h Top Divergence Warning', text = '1h Top Divergence', refSeries = high, color='red', fontSize=14, placement='top' ,display=true);

// Define alert conditions

alertcondition(invdiv1h, title='1h Bottom Divergence Warning', direction="buy")

alertcondition(invdiv11h, title='1h Top Divergence Warning', direction="sell")

2. Continue to copy the 30-minute code

30-minute Divergence Signal Code Sharing

// Divergence at the minute level 30 minutes

rets30m = security(syminfo.tickerid, '30m', funcinvisible_divergence(open, high, low, close))

invdiv30m = rets_30m{0}

invdiv130m = rets_30m{1}

// Draw the signal

plotText(invdiv30m, title='30m Bottom Divergence Warning', text = '30m Bottom Divergence', refSeries = low, color='green', fontSize=14, placement='bottom' ,display=true);

plotText(invdiv130m, title='30m Top Divergence Warning', text = '30m Top Divergence', refSeries = high, color='red', fontSize=14, placement='top' ,display=true);

// Define alert conditions

alertcondition(invdiv30m, title='30m Bottom Divergence Warning', direction="buy")

alertcondition(invdiv130m, title='30m Top Divergence Warning', direction="sell")

3. Displaying top and bottom divergences for 4-hour, 1-hour, and 30-minute periods

By adding the above code and clicking to display the candlestick chart, you can see the top and bottom divergences for the 4-hour, 1-hour, and 30-minute periods on the candlestick chart.

IV. Setting Alert Reminders for MACD Indicator Divergence

1. Set alert conditions for each period as shown in the image

2. After setting the alert, click to enable the alert

3. There are various ways to set alerts to track the market and not miss signals

V. Q&A

  1. Do I need to keep the AICoin trading grid software running on my computer all the time? Will the program be affected if the computer goes to sleep?

Yes, you need to keep the computer running to maintain the software operation, or you can buy a cloud server to run it, such as purchasing a Windows version of a cloud server to keep it running continuously.

  1. Can I set multiple periods for the indicators?

You can write several divergence scripts to achieve this.

PRO members and signal alert members have access to premium tools tailored for lazy traders, including custom indicators to help plan their trades and trade their plans. For more custom indicator strategy displays and multiple alert reminders, feel free to subscribe to the Signal Alert/PRO K-line version, both of which offer a limited-time free trial of custom indicator membership. Click the link below to subscribe and experience: https://aicoin.app/zh-CN/vip/chartpro

Recommended Reading

  1. Combining Candlestick Patterns and Trend Lines to Capture Trading Signals from a New Perspective

  2. AI-Generated Indicators, Automated Trading, Easily Start Bottom-Fishing Strategy to Make Money in a New Mode

  3. Three Steps to Select Potential Coins: Master These Three Techniques to Easily Grasp the Market Pulse

For more live broadcast content, please follow the "Live Review" section in AICoin's news/information, and feel free to download the AICoin PC version.

免责声明:本文章仅代表作者个人观点,不代表本平台的立场和观点。本文章仅供信息分享,不构成对任何人的任何投资建议。用户与作者之间的任何争议,与本平台无关。如网页中刊载的文章或图片涉及侵权,请提供相关的权利证明和身份证明发送邮件到support@aicoin.com,本平台相关工作人员将会进行核查。

注册返10%、领$600,前100名赠送PRO会员
链接:https://accounts.suitechsui.blue/zh-CN/register?ref=FRV6ZPAF&return_to=aHR0cHM6Ly93d3cuc3VpdGVjaHN1aS5hY2FkZW15L3poLUNOL2pvaW4_cmVmPUZSVjZaUEFG
Ad
Share To
APP

X

Telegram

Facebook

Reddit

CopyLink