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

- Channel: 量化交易科學園區 - 江加宏
- Published: 2023-03-29
- Series: [Quant Trading Science Park](https://xknow.app/en/s/quant-trading-science-park/?ref=agent) ([series index](https://xknow.app/en/s/quant-trading-science-park/llms.txt))
- Topics: [Technical Analysis](https://xknow.app/en/topics/technicals/llms.txt), [AI & Software Engineering](https://xknow.app/en/topics/ai-engineering/llms.txt)
- Page: https://xknow.app/en/v/quant-trading-science-park-ep11/?ref=agent
- YouTube: https://www.youtube.com/watch?v=rS0a4Zvk07o

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

## Section summaries

### 0:05 Recreating 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.

[Page](https://xknow.app/en/v/quant-trading-science-park-ep11/?ref=agent#s-0) | [YouTube 0:05](https://www.youtube.com/watch?v=rS0a4Zvk07o&t=5s)

### 1:25 Building 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.

[Page](https://xknow.app/en/v/quant-trading-science-park-ep11/?ref=agent#s-1) | [YouTube 1:25](https://www.youtube.com/watch?v=rS0a4Zvk07o&t=85s)

### 10:45 Backtested 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.

[Page](https://xknow.app/en/v/quant-trading-science-park-ep11/?ref=agent#s-2) | [YouTube 10:45](https://www.youtube.com/watch?v=rS0a4Zvk07o&t=645s)

---

Full notes (with slides) and other episodes in this series: https://xknow.app/en/v/quant-trading-science-park-ep11/?ref=agent

Watch the original video: https://www.youtube.com/watch?v=rS0a4Zvk07o
