Recreating the Day-Trading Three Lines and a Short Alert for Breakouts That Fall Back, Using XS

TL;DR: The day-trading three lines need only the high and low of today's highest-volume candlestick plus today's average price line, so they can be written in XS with a few variables, and a short alert can be added for a breakout that falls back below the lines.

Key ideas

  • The three lines are simple: the high and low of today's highest-volume candlestick, plus today's average price line, all watched together on the intraday minute chart.
  • The logic first uses GetBarOffset to work out which candlestick of today the current bar is, counting from the 1st; the 1st bar takes its own high and low directly, and afterwards, whenever a bar sets the day's highest volume, the high and low are updated to that bar's.
  • The average price line can be obtained directly with GetField for average price; when plotting, the upper line is red, the lower line is green, the average price line is yellow, and the scale range uses price coordinates.
  • The short alert condition is that today's high is a set percentage above the three lines and the current price has fallen a set percentage below the three lines; when met it returns 1, so the alert arrives during the trading session.
  • Backtesting the last few days of data, stocks such as 8086 and 8044 showed the pattern of first breaking above the three lines and then falling back below them.
量化交易科學園區 - 江加宏Length 12:36Quant Trading Science Park
Episodes
  1. Mon, Nov 28Custom SwingHighBar: Finding Perfect Peaks with Rising Left Side and Falling Right Side
  2. Sat, Dec 31Automatically Detecting an M-Top with XScript: Swing Highs, Neckline and Multiple Filter Conditions
  3. Thu, Mar 16Detecting Volume-Price Divergence with Code: Comparing Price and Volume at Two Swing Highs
  4. Wed, Mar 29Recreating the Day-Trading Three Lines and a Short Alert for Breakouts That Fall Back, Using XS
  5. Tue, Apr 11RSI Bearish Divergence Algorithm and Tolerant Sampling: Syncing Price Highs with Indicator Highs
  6. Thu, Apr 20Measuring Bullish Strength from a Single Candlestick
  7. Fri, Apr 28Manual Entry, Automatic Exit: Using XQ Semi-Automated Trading to Free Up Office Workers
  8. Sun, May 14Automated Trading Without Coding Skills: Split a Strategy into Four Building Blocks of Stock Selection, Entry, Exit and Position Control
  9. Mon, Jun 5Is a High-Volume Long Upper Shadow a Reversal or a Bullish Shakeout? A 3-Year Backtest
  10. Sat, Jun 17Picking Stocks at the Second-Wave Breakout: Big Prior Rally, Low-Volume Consolidation, Then a High-Volume Long Red Candle
  11. Wed, Sep 23Disposition stocks no longer pull back under the new rules: buy those that close strong on day 1 and sell on day 5
  12. Wed, Oct 7A Live Trading Strategy Under the New Disposition Stock Rules: Buy on Day 1, Sell on the Last Day, and Use Stop-Losses
  13. Wed, Oct 21Foreign Capital Rotates Into Defensive Stocks, and a Review of Live Disposition Stock Trades
  14. Wed, Oct 28SDT Shared Variables: Fixed Memory That Saves Resources and Lets Instruments in the Same Strategy Pass Data to Each Other
  15. Wed, Nov 4Disposition Stock Strategy Flips From Bull to Bear: Why It Is Paused When the Market Weakens
  16. Wed, Nov 18Auditing Online Course Strategies with AI: Out-of-Sample Backtesting and Building Your Own XQ Minute-Bar Database
  17. Wed, Nov 25Options Long Straddle Backtest: Trading It Every Day Loses Over the Long Run, With Chances to Profit Only in High-Volatility Periods
▶ Watch the original on YouTube
Ask AI about this episode

Copy the prompt, paste it into an AI service, and add the question. The AI reads the notes on this site and links to the page and the video timestamps.

Or open directly:ChatGPTClaudeGrokPerplexity

Section summaries

  1. 0:05Recreating External Indicators in XQ and Shun Ge's Three Lines

    The speaker notes that most personal indicators of well-known traders can be recreated in XQ. Taking Shun Ge as an example, he watches three lines on the minute chart: the low of today's highest-volume candlestick, the high of today's highest-volume candlestick, and today's average price line. The speaker then announces that these three lines will be built with XS.

    ▶ Watch from here
    Slide: Recreating External Indicators in XQ and Shun Ge's Three Lines
  2. 1:25Building the Three Lines and the Short Alert Condition in XS

    After adding a new indicator, declare variables for Top, Bottom, the average price line, and a counter for the number of candlesticks. Use GetBarOffset with today's date and 9 o'clock sharp, then add 1 to get which candlestick of today it is. The 1st bar takes its high and low directly; afterwards, whenever volume is the day's highest, Top and Bottom are updated to that bar's high and low, while the average price line is obtained with GetField. One of Shun Ge's uses is that when price breaks above the three lines and then falls back below them, it is seen as a short-selling opportunity. The alert condition requires today's high to be a set percentage above the three lines and the current price to be a set percentage below them, and returns 1 when met.

    ▶ Watch from here
    Slide: Building the Three Lines and the Short Alert Condition in XS
  3. 10:45Backtested Stock Examples and Course Notes

    The backtest covers only the last few days, using this script for entries. It found stocks such as 8086 and 8044, which during the session both broke above the three lines by a set margin and then fell back below them, matching the signal. The speaker says more in-depth ways of trading it are not his specialty, so he does not comment further.

    ▶ Watch from here

This page summarizes the video; it is not an official transcript. Original video: Recreating the Day-Trading Three Lines and a Short Alert for Breakouts That Fall Back, Using XS (量化交易科學園區 - 江加宏), copyright belongs to the original creator.