Strategy · Pine Script v6 · On the chart

PA Strategy Backtest

by Chovy-King

A strategy version of a price-action signal set with eleven switchable entry setups, such as trend breakout, trend pullback, false breakout of a key level, range edge, breakout retest and double top or bottom.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code541
Settings39inputs
LicenceNone stated
Last update6 months ago30 Apr 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

Levels come from clustered swing points, with 20, 60 and 144 moving averages for trend. Each trade has a stop beyond the swing with an ATR buffer and two targets at risk multiples, with a partial exit at the first. Sizing is a percent of equity with commission and slippage set.

Details

Published by

Chovy-King on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Support & resistance, Trend, Breakout

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
短期均线 EMA 周期(默认 20)int20maFastLen
中期均线 EMA 周期(默认 60)int60maMidLen
长期均线 EMA 周期(默认 144)int144maSlowLen
均线类型(EMA / SMA)stringEMAuseEMAorSMA
波段点左侧 K 线数int3swingLeft
波段点右侧 K 线数int3swingRight
关键水平聚合容差(%)float0.25clusterTolPct
保留最近波段点数量int40maxSwings
关键水平最少触碰次数int2minTouches
关键水平仅回看最近N根K线int200levelLookback
① 顺势突破入场booltrueenBreakout
② 顺势回撤入场(推荐)booltrueenPullback
Show all 39 settings
SettingTypeDefaultVariable
③ 关键水平假突破booltrueenFalseBreak
④ 区间边缘交易booltrueenRange
⑤ 突破回调入场(支阻互换)booltrueenRetest
⑥ 双顶/双底反转booltrueenDoubleTB
⑦ 强趋势弱回撤延续booltrueenStrongWeak
⑧ 趋势尖峰反转(高胜率低)boolfalseenClimaxRev
⑨ 动能衰竭/三推反转boolfalseenExhaustion
⑩ 失败反转顺势再入场booltrueenFailedRev
⑪ 均值回归(偏离 MA144)boolfalseenMeanRev
启用 HTF 共振过滤(与高周期趋势同向)boolfalseenHTF
高周期 HTFtimeframe240htfTF
止损在摆动点外再扩 N 倍 ATRfloat0.3slBufferATR
ATR 周期int14atrLen
止盈1 = N 倍风险 R(默认 2R)float2.0rr1
止盈2 = N 倍风险 R(默认 3R)float3.0rr2
限制回测日期范围boolfalseuseDateRange
开始时间timetimestamp("01 Jan 2020 00:00 +0000")startDate
结束时间timetimestamp("31 Dec 2099 23:59 +0000")endDate
单笔风险占账户 %(1 = 仅亏 1%)float1.0riskPerTrade
按单笔风险%动态计算仓位(覆盖默认 default_qty_value)booltrueuseRiskSizing
分批止盈:先 TP1 平掉 N%,剩余 TP2 平仓booltrueuseTPSplit
TP1 平仓比例 %float50.0tp1PctClose
TP1 触发后把 SL 移到入场价(保本,类似书中做法)booltruemoveSLToBE
允许做多booltrueallowLong
允许做空booltrueallowShort
显示 3 条均线booltrueshowMA
信号 K 线背景高亮booltrueshowSignalsBG
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr

Strategy v6 BreakoutTrend
Updated yesterday · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout
257 stars

This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos

Strategy v6 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Best Chart 1m Strategy Candle Bar
106 stars

Calculates multi-period logarithmic regression trend channels and deviation bands across up to twenty selectable lookback lengths directly on the price chart. It evaluates channel slopes and Pearson's correlation coefficient to detect market trends and generat

Strategy v5 TrendSupport & resistance Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced Trend Detection Strategy

This trend breakout strategy plots Donchian Channels consisting of upper, lower, and middle bands directly on the main price chart. Long positions enter when price touches the upper channel and pulls back to or below the middle band, placing a stop loss at the

Strategy v6 TrendBreakout
Updated 2 months ago · MPL-2.0 GitHub repository of Donchian Strategy - Dynamic TP, Fixed SL, 1% Risk, Daily Target
43 stars

This strategy executes trades on short-term cryptocurrency charts using a combination of pivot support and resistance levels and a multi-pole smoothed trend filter. Entries trigger when price crosses the smoothed trend line and confirms above or below a short-

Strategy v5 TrendBreakout Repaints
Updated 2 years ago · None stated GitHub repository of SOL 1m - Strategy Candle Bar

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers