OPEN-SOURCE SCRIPT
Trend Friend

Trend Friend — What it is and how to use it
I built Trend Friend to stop redrawing the same trendlines all day. It automatically connects confirmed swing points (fractals) and keeps the most relevant lines in front of you. The goal: give you clean, actionable structure without the guesswork.
What it does (in plain English)
Finds swing highs/lows using a Fractal Period you choose.
Draws auto-trendlines between the two most recent confirmed highs and the two most recent confirmed lows.
Colours by intent:
Lines drawn from highs (potential resistance / bearish) = Red
Lines drawn from lows (potential support / bullish) = Green
Keeps the chart tidy: The newest lines are styled as “recent,” older lines are dimmed as “historical,” and it prunes anything beyond your chosen limit.
Optional crosses & alerts: You can highlight when price closes across the most recent line and set alerts for new lines formed and upper/lower line crosses.
Structure labels: It tags HH, LH, HL, LL at the swing points, so you can quickly read trend/rotation.
How it works (under the hood)
A “fractal” here is a confirmed pivot: the highest high (or lowest low) with n bars on each side. That means pivots only confirm after n bars, so signals are cleaner and less noisy.
When a new pivot prints, the script connects it to the prior pivot of the same type (high→high, low→low). That gives you one “bearish” line from highs and one “bullish” line from lows.
The newest line is marked as recent (brighter), and the previous recent line becomes historical (dimmed). You can keep as many pairs as you want, but I usually keep it tight.
Inputs you’ll actually use
Fractal Period (n): this is the big one. It controls how swingy/strict the pivots are.
Lower n → more swings, more lines (faster, noisier)
Higher n → fewer swings, cleaner lines (slower, swing-trade friendly)
Max pair of lines: how many pairs (up+down) to keep on the chart. 1–3 is a sweet spot.
Extend: extend lines Right (my default) or Both ways if you like the context.
Line widths & colours: recent vs. historical are separate so you can make the active lines pop.
Show crosses: toggle the X markers when price crosses a line. I turn this on when I’m actively hunting breakouts/retests.
Reading the chart
Red lines (from highs): I treat these as potential resistance. A clean break + hold above a red line often flips me from “fade” to “follow.”
Green lines (from lows): Potential support. Same idea in reverse: break + hold below and I stop buying dips until I see structure reclaim.
HH / LH / HL / LL dots: quick read on structure.
HH/HL bias = uptrend continuation potential
LH/LL bias = downtrend continuation potential
Mixed prints = rotation/chop—tighten risk or wait for clarity.
My H1 guidance (fine-tuning Fractal Period)
If you’re mainly on H1 (my use case), tune like this:
Fast / aggressive: n = 6–8 (lots of signals, good for momentum days; more chop risk)
Balanced (recommended): n = 9–12 (keeps lines meaningful but responsive)
Slow / swing focus: n = 13–21 (filters noise; better for trend days and higher-TF confluence)
Rule of thumb: if you’re getting too many touches and whipsaws, increase n. If you’re late to obvious breaks, decrease n.
How I trade it (example workflow)
Pick your n for the session (H1: start at 9–12).
Mark the recent red & green lines. That’s your immediate structure.
Look for interaction:
Rejections from a line = fade potential back into the range.
Break + close across a line = watch the retest for continuation.
Confirm with context: session bias, HTF structure, and your own tools (VWAP, RSI, volume, FVG/OB, etc.).
Plan the trade: enter on retest or reclaim, stop beyond the line/last swing, target the opposite side or next structure.
Alerts (set and forget)
“New trendline formed” — fires when a new high/low pivot confirms and a fresh line is drawn.
“Upper/lower trendline crossed” — fires when price crosses the most recent red/green line.
Use these to track structure shifts without staring at the screen.
Good to know (honest limitations)
Confirmation lag: pivots need n bars on both sides, so signals arrive after the swing confirms. That’s by design—less noise, fewer fake lines.
Lines update as structure evolves: when a new pivot forms, the previous “recent” line becomes “historical,” and older ones can be removed based on your max setting.
Not an auto trendline crystal ball: it won’t predict which line holds or breaks—it just keeps the most relevant structure clean and up to date.
Final notes
Works on any timeframe; I built it with H1 in mind and scale to H4/D1 by increasing n.
Pairs nicely with session tools and VWAP for intraday, or with supply/demand / FVGs for swing planning.
Risk first: lines are structure, not guarantees. Manage position size and stops as usual.
Not financial advice. Trade your plan. Stay nimble.
I built Trend Friend to stop redrawing the same trendlines all day. It automatically connects confirmed swing points (fractals) and keeps the most relevant lines in front of you. The goal: give you clean, actionable structure without the guesswork.
What it does (in plain English)
Finds swing highs/lows using a Fractal Period you choose.
Draws auto-trendlines between the two most recent confirmed highs and the two most recent confirmed lows.
Colours by intent:
Lines drawn from highs (potential resistance / bearish) = Red
Lines drawn from lows (potential support / bullish) = Green
Keeps the chart tidy: The newest lines are styled as “recent,” older lines are dimmed as “historical,” and it prunes anything beyond your chosen limit.
Optional crosses & alerts: You can highlight when price closes across the most recent line and set alerts for new lines formed and upper/lower line crosses.
Structure labels: It tags HH, LH, HL, LL at the swing points, so you can quickly read trend/rotation.
How it works (under the hood)
A “fractal” here is a confirmed pivot: the highest high (or lowest low) with n bars on each side. That means pivots only confirm after n bars, so signals are cleaner and less noisy.
When a new pivot prints, the script connects it to the prior pivot of the same type (high→high, low→low). That gives you one “bearish” line from highs and one “bullish” line from lows.
The newest line is marked as recent (brighter), and the previous recent line becomes historical (dimmed). You can keep as many pairs as you want, but I usually keep it tight.
Inputs you’ll actually use
Fractal Period (n): this is the big one. It controls how swingy/strict the pivots are.
Lower n → more swings, more lines (faster, noisier)
Higher n → fewer swings, cleaner lines (slower, swing-trade friendly)
Max pair of lines: how many pairs (up+down) to keep on the chart. 1–3 is a sweet spot.
Extend: extend lines Right (my default) or Both ways if you like the context.
Line widths & colours: recent vs. historical are separate so you can make the active lines pop.
Show crosses: toggle the X markers when price crosses a line. I turn this on when I’m actively hunting breakouts/retests.
Reading the chart
Red lines (from highs): I treat these as potential resistance. A clean break + hold above a red line often flips me from “fade” to “follow.”
Green lines (from lows): Potential support. Same idea in reverse: break + hold below and I stop buying dips until I see structure reclaim.
HH / LH / HL / LL dots: quick read on structure.
HH/HL bias = uptrend continuation potential
LH/LL bias = downtrend continuation potential
Mixed prints = rotation/chop—tighten risk or wait for clarity.
My H1 guidance (fine-tuning Fractal Period)
If you’re mainly on H1 (my use case), tune like this:
Fast / aggressive: n = 6–8 (lots of signals, good for momentum days; more chop risk)
Balanced (recommended): n = 9–12 (keeps lines meaningful but responsive)
Slow / swing focus: n = 13–21 (filters noise; better for trend days and higher-TF confluence)
Rule of thumb: if you’re getting too many touches and whipsaws, increase n. If you’re late to obvious breaks, decrease n.
How I trade it (example workflow)
Pick your n for the session (H1: start at 9–12).
Mark the recent red & green lines. That’s your immediate structure.
Look for interaction:
Rejections from a line = fade potential back into the range.
Break + close across a line = watch the retest for continuation.
Confirm with context: session bias, HTF structure, and your own tools (VWAP, RSI, volume, FVG/OB, etc.).
Plan the trade: enter on retest or reclaim, stop beyond the line/last swing, target the opposite side or next structure.
Alerts (set and forget)
“New trendline formed” — fires when a new high/low pivot confirms and a fresh line is drawn.
“Upper/lower trendline crossed” — fires when price crosses the most recent red/green line.
Use these to track structure shifts without staring at the screen.
Good to know (honest limitations)
Confirmation lag: pivots need n bars on both sides, so signals arrive after the swing confirms. That’s by design—less noise, fewer fake lines.
Lines update as structure evolves: when a new pivot forms, the previous “recent” line becomes “historical,” and older ones can be removed based on your max setting.
Not an auto trendline crystal ball: it won’t predict which line holds or breaks—it just keeps the most relevant structure clean and up to date.
Final notes
Works on any timeframe; I built it with H1 in mind and scale to H4/D1 by increasing n.
Pairs nicely with session tools and VWAP for intraday, or with supply/demand / FVGs for swing planning.
Risk first: lines are structure, not guarantees. Manage position size and stops as usual.
Not financial advice. Trade your plan. Stay nimble.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.