@tradejs/strategy-trend-follow 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,15 @@ exit on the trailing stop or an opposite signal.
13
13
 
14
14
  ![TrendFollow strategy logic](https://raw.githubusercontent.com/TradeJS-Dev/TradeJS-Strategy-TrendFollow/main/docs/strategy-logic.svg)
15
15
 
16
+ ## Signal on an example chart
17
+
18
+ The purple ATR-offset trail holds the bearish regime until price crosses it and the bounded state flips upward; optional context filters then qualify the LONG.
19
+
20
+ ![TrendFollow signal on an illustrative ticker chart](https://raw.githubusercontent.com/TradeJS-Dev/TradeJS-Strategy-TrendFollow/main/docs/signal-example.svg)
21
+
22
+ The illustration is schematic, not market data. Exact thresholds, confirmation
23
+ rules, and risk parameters come from the active TradeJS strategy config.
24
+
16
25
  ## Install
17
26
 
18
27
  ```bash
@@ -0,0 +1,114 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 560" role="img" aria-labelledby="title description">
2
+ <title id="title">TrendFollow signal on an illustrative ticker chart</title>
3
+ <desc id="description">Price flips through an ATR-offset trailing regime. The chart is schematic and does not represent live market data.</desc>
4
+ <defs>
5
+ <linearGradient id="background" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#08111f"/><stop offset="100%" stop-color="#111b32"/></linearGradient>
6
+ <linearGradient id="plot" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#101b30"/><stop offset="100%" stop-color="#0b1426"/></linearGradient>
7
+ <filter id="shadow" x="-20%" y="-20%" width="140%" height="150%"><feDropShadow dx="0" dy="7" stdDeviation="9" flood-color="#020617" flood-opacity="0.42"/></filter>
8
+ <style>
9
+ .title{fill:#f8fafc;font:700 28px Inter,ui-sans-serif,system-ui,sans-serif}.subtitle{fill:#94a3b8;font:400 15px Inter,ui-sans-serif,system-ui,sans-serif}.brand{fill:#475569;font:600 13px Inter,ui-sans-serif,system-ui,sans-serif;letter-spacing:.08em}.panel{fill:url(#plot);stroke:#26364f;stroke-width:1.5;filter:url(#shadow)}.grid{stroke:#20304a;stroke-width:1}.axis{fill:#64748b;font:600 10px Inter,ui-sans-serif,system-ui,sans-serif;letter-spacing:.08em}.overlay-label{fill:#cbd5e1;font:600 11px Inter,ui-sans-serif,system-ui,sans-serif}.annotation{fill:#e2e8f0;font:600 11px Inter,ui-sans-serif,system-ui,sans-serif}.condition-title{fill:#64748b;font:700 11px Inter,ui-sans-serif,system-ui,sans-serif;letter-spacing:.09em}.condition-number{fill:#08111f;font:800 12px Inter,ui-sans-serif,system-ui,sans-serif}.condition-copy{fill:#e2e8f0;font:500 13px Inter,ui-sans-serif,system-ui,sans-serif}.footer{fill:#94a3b8;font:500 12px Inter,ui-sans-serif,system-ui,sans-serif}.signal{fill:#08111f;font:800 11px Inter,ui-sans-serif,system-ui,sans-serif;letter-spacing:.03em}.risk{font:700 10px Inter,ui-sans-serif,system-ui,sans-serif;letter-spacing:.06em}
10
+ </style>
11
+ </defs>
12
+ <rect width="1200" height="560" rx="24" fill="url(#background)"/>
13
+ <text x="32" y="45" class="title">TrendFollow</text>
14
+ <text x="32" y="72" class="subtitle">Price flips through an ATR-offset trailing regime</text>
15
+ <text x="1168" y="45" text-anchor="end" class="brand">TRADEJS</text>
16
+ <rect x="32" y="104" width="790" height="416" rx="18" class="panel"/>
17
+ <rect x="842" y="104" width="326" height="416" rx="18" class="panel"/>
18
+ <text x="58" y="134" class="axis">ILLUSTRATIVE TICKER</text>
19
+ <text x="796" y="134" text-anchor="end" class="axis">SCHEMATIC • NOT LIVE DATA</text>
20
+ <line x1="58" y1="162.0" x2="796" y2="162.0" class="grid"/>
21
+ <line x1="58" y1="240.0" x2="796" y2="240.0" class="grid"/>
22
+ <line x1="58" y1="318.0" x2="796" y2="318.0" class="grid"/>
23
+ <line x1="58" y1="396.0" x2="796" y2="396.0" class="grid"/>
24
+ <line x1="58" y1="474.0" x2="796" y2="474.0" class="grid"/>
25
+ <line x1="58.0" y1="162" x2="58.0" y2="474" class="grid"/>
26
+ <line x1="205.6" y1="162" x2="205.6" y2="474" class="grid"/>
27
+ <line x1="353.2" y1="162" x2="353.2" y2="474" class="grid"/>
28
+ <line x1="500.8" y1="162" x2="500.8" y2="474" class="grid"/>
29
+ <line x1="648.4" y1="162" x2="648.4" y2="474" class="grid"/>
30
+ <line x1="796.0" y1="162" x2="796.0" y2="474" class="grid"/>
31
+ <line x1="58.0" y1="288.2" x2="58.0" y2="306.6" stroke="#34d399" stroke-width="1.5"/>
32
+ <rect x="51.5" y="293.7" width="13.0" height="5.5" rx="2" fill="#34d399"/>
33
+ <line x1="87.5" y1="282.0" x2="87.5" y2="316.6" stroke="#f87171" stroke-width="1.5"/>
34
+ <rect x="81.0" y="289.3" width="13.0" height="18.3" rx="2" fill="#f87171"/>
35
+ <line x1="117.0" y1="299.7" x2="117.0" y2="327.0" stroke="#f87171" stroke-width="1.5"/>
36
+ <rect x="110.5" y="308.8" width="13.0" height="12.7" rx="2" fill="#f87171"/>
37
+ <line x1="146.6" y1="320.1" x2="146.6" y2="349.5" stroke="#f87171" stroke-width="1.5"/>
38
+ <rect x="140.1" y="325.6" width="13.0" height="16.6" rx="2" fill="#f87171"/>
39
+ <line x1="176.1" y1="332.8" x2="176.1" y2="365.1" stroke="#f87171" stroke-width="1.5"/>
40
+ <rect x="169.6" y="340.0" width="13.0" height="16.1" rx="2" fill="#f87171"/>
41
+ <line x1="205.6" y1="343.5" x2="205.6" y2="375.5" stroke="#f87171" stroke-width="1.5"/>
42
+ <rect x="199.1" y="352.5" width="13.0" height="17.5" rx="2" fill="#f87171"/>
43
+ <line x1="235.1" y1="367.6" x2="235.1" y2="391.1" stroke="#f87171" stroke-width="1.5"/>
44
+ <rect x="228.6" y="373.2" width="13.0" height="10.7" rx="2" fill="#f87171"/>
45
+ <line x1="264.6" y1="379.4" x2="264.6" y2="406.7" stroke="#f87171" stroke-width="1.5"/>
46
+ <rect x="258.1" y="386.7" width="13.0" height="11.1" rx="2" fill="#f87171"/>
47
+ <line x1="294.2" y1="384.8" x2="294.2" y2="417.1" stroke="#f87171" stroke-width="1.5"/>
48
+ <rect x="287.7" y="393.9" width="13.0" height="17.7" rx="2" fill="#f87171"/>
49
+ <line x1="323.7" y1="404.3" x2="323.7" y2="432.7" stroke="#f87171" stroke-width="1.5"/>
50
+ <rect x="317.2" y="409.8" width="13.0" height="15.7" rx="2" fill="#f87171"/>
51
+ <line x1="353.2" y1="422.5" x2="353.2" y2="441.4" stroke="#f87171" stroke-width="1.5"/>
52
+ <rect x="346.7" y="429.8" width="13.0" height="2.6" rx="2" fill="#f87171"/>
53
+ <line x1="382.7" y1="416.5" x2="382.7" y2="438.6" stroke="#34d399" stroke-width="1.5"/>
54
+ <rect x="376.2" y="425.5" width="13.0" height="7.6" rx="2" fill="#34d399"/>
55
+ <line x1="412.2" y1="406.1" x2="412.2" y2="428.2" stroke="#34d399" stroke-width="1.5"/>
56
+ <rect x="405.7" y="411.6" width="13.0" height="9.4" rx="2" fill="#34d399"/>
57
+ <line x1="441.8" y1="383.5" x2="441.8" y2="421.1" stroke="#34d399" stroke-width="1.5"/>
58
+ <rect x="435.3" y="390.8" width="13.0" height="21.3" rx="2" fill="#34d399"/>
59
+ <line x1="471.3" y1="361.0" x2="471.3" y2="400.7" stroke="#34d399" stroke-width="1.5"/>
60
+ <rect x="464.8" y="370.0" width="13.0" height="25.2" rx="2" fill="#34d399"/>
61
+ <line x1="500.8" y1="343.7" x2="500.8" y2="375.7" stroke="#34d399" stroke-width="1.5"/>
62
+ <rect x="494.3" y="349.2" width="13.0" height="19.2" rx="2" fill="#34d399"/>
63
+ <line x1="530.3" y1="321.1" x2="530.3" y2="354.3" stroke="#34d399" stroke-width="1.5"/>
64
+ <rect x="523.8" y="328.4" width="13.0" height="16.8" rx="2" fill="#34d399"/>
65
+ <line x1="559.8" y1="298.6" x2="559.8" y2="336.6" stroke="#34d399" stroke-width="1.5"/>
66
+ <rect x="553.3" y="307.6" width="13.0" height="23.4" rx="2" fill="#34d399"/>
67
+ <line x1="589.4" y1="288.2" x2="589.4" y2="318.2" stroke="#34d399" stroke-width="1.5"/>
68
+ <rect x="582.9" y="293.7" width="13.0" height="17.1" rx="2" fill="#34d399"/>
69
+ <line x1="618.9" y1="272.6" x2="618.9" y2="299.3" stroke="#34d399" stroke-width="1.5"/>
70
+ <rect x="612.4" y="279.9" width="13.0" height="10.4" rx="2" fill="#34d399"/>
71
+ <line x1="648.4" y1="257.0" x2="648.4" y2="283.0" stroke="#34d399" stroke-width="1.5"/>
72
+ <rect x="641.9" y="266.0" width="13.0" height="11.5" rx="2" fill="#34d399"/>
73
+ <line x1="677.9" y1="246.6" x2="677.9" y2="277.4" stroke="#34d399" stroke-width="1.5"/>
74
+ <rect x="671.4" y="252.1" width="13.0" height="18.0" rx="2" fill="#34d399"/>
75
+ <line x1="707.4" y1="231.0" x2="707.4" y2="262.5" stroke="#34d399" stroke-width="1.5"/>
76
+ <rect x="700.9" y="238.3" width="13.0" height="15.2" rx="2" fill="#34d399"/>
77
+ <line x1="737.0" y1="215.4" x2="737.0" y2="239.4" stroke="#34d399" stroke-width="1.5"/>
78
+ <rect x="730.5" y="224.4" width="13.0" height="9.4" rx="2" fill="#34d399"/>
79
+ <line x1="766.5" y1="205.0" x2="766.5" y2="231.5" stroke="#34d399" stroke-width="1.5"/>
80
+ <rect x="760.0" y="210.5" width="13.0" height="13.7" rx="2" fill="#34d399"/>
81
+ <line x1="796.0" y1="189.4" x2="796.0" y2="224.0" stroke="#34d399" stroke-width="1.5"/>
82
+ <rect x="789.5" y="196.7" width="13.0" height="18.4" rx="2" fill="#34d399"/>
83
+ <polyline points="58.0,266.0 87.5,279.9 117.0,293.7 146.6,307.6 176.1,321.5 205.6,335.3 235.1,349.2 264.6,363.1 294.2,376.9 323.7,390.8 353.2,397.7 382.7,397.7 412.2,397.7 441.8,394.3 471.3,390.8 500.8,383.9 530.3,376.9 559.8,363.1 589.4,349.2 618.9,335.3 648.4,321.5 677.9,307.6 707.4,293.7 737.0,279.9 766.5,266.0 796.0,252.1" fill="none" stroke="#c084fc" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/>
84
+ <text x="791.0" y="244.1" text-anchor="end" class="overlay-label">ATR trailing state</text>
85
+ <circle cx="471.3" cy="370.0" r="4.5" fill="#f8fafc" stroke="#08111f" stroke-width="2"/>
86
+ <line x1="471.3" y1="376.0" x2="471.3" y2="389.0" stroke="#64748b" stroke-width="1.2"/>
87
+ <text x="471.3" y="401.0" text-anchor="middle" class="annotation">Trail flip</text>
88
+ <line x1="471.3" y1="162" x2="471.3" y2="474" stroke="#34d399" stroke-width="1.5" stroke-dasharray="4 5" stroke-opacity=".75"/>
89
+ <polygon points="464.28,413 478.28,413 471.28,402" fill="#34d399"/>
90
+ <rect x="419.3" y="419.0" width="104.0" height="23" rx="11.5" fill="#34d399"/>
91
+ <text x="471.3" y="434.5" text-anchor="middle" class="signal">Regime LONG</text>
92
+ <line x1="489.3" y1="182.8" x2="796" y2="182.8" stroke="#34d399" stroke-width="1.5" stroke-dasharray="5 5"/>
93
+ <text x="791.0" y="177.8" text-anchor="end" class="risk" fill="#34d399">TARGET</text>
94
+ <line x1="489.3" y1="397.7" x2="796" y2="397.7" stroke="#f87171" stroke-width="1.5" stroke-dasharray="5 5"/>
95
+ <text x="791.0" y="392.7" text-anchor="end" class="risk" fill="#f87171">INVALIDATION</text>
96
+ <text x="866" y="136" class="condition-title">WHAT THE STRATEGY SEES</text>
97
+ <rect x="862" y="158" width="286" height="69" rx="13" fill="#111c31" stroke="#26364f"/>
98
+ <circle cx="884" cy="180" r="13" fill="#22d3ee"/>
99
+ <text x="884" y="184" text-anchor="middle" class="condition-number">1</text>
100
+ <text x="905" y="179" class="condition-copy"><tspan x="905" dy="0">Replayable pivots update trend</tspan><tspan x="905" dy="18">structure</tspan></text>
101
+ <rect x="862" y="241" width="286" height="69" rx="13" fill="#111c31" stroke="#26364f"/>
102
+ <circle cx="884" cy="263" r="13" fill="#60a5fa"/>
103
+ <text x="884" y="267" text-anchor="middle" class="condition-number">2</text>
104
+ <text x="905" y="262" class="condition-copy"><tspan x="905" dy="0">ATR offset defines the</tspan><tspan x="905" dy="18">trailing state</tspan></text>
105
+ <rect x="862" y="324" width="286" height="69" rx="13" fill="#111c31" stroke="#26364f"/>
106
+ <circle cx="884" cy="346" r="13" fill="#f59e0b"/>
107
+ <text x="884" y="350" text-anchor="middle" class="condition-number">3</text>
108
+ <text x="905" y="345" class="condition-copy"><tspan x="905" dy="0">Price crosses and flips</tspan><tspan x="905" dy="18">direction</tspan></text>
109
+ <rect x="862" y="407" width="286" height="69" rx="13" fill="#111c31" stroke="#26364f"/>
110
+ <circle cx="884" cy="429" r="13" fill="#34d399"/>
111
+ <text x="884" y="433" text-anchor="middle" class="condition-number">4</text>
112
+ <text x="905" y="428" class="condition-copy"><tspan x="905" dy="0">Optional structure, volume,</tspan><tspan x="905" dy="18">and regime filters pass</tspan></text>
113
+ <text x="32" y="545" class="footer">LONG EXAMPLE • MIRRORED RULES CAN PRODUCE THE OPPOSITE SIDE • EXACT THRESHOLDS ARE CONFIGURABLE</text>
114
+ </svg>
@@ -0,0 +1,97 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 360" role="img" aria-labelledby="title description">
2
+ <title id="title">TrendFollow strategy logic</title>
3
+ <desc id="description">Pivot structure → ATR trail → directional regime change. Upward trail flip → LONG; downward trail flip → SHORT.</desc>
4
+ <defs>
5
+ <linearGradient id="background" x1="0" y1="0" x2="1" y2="1">
6
+ <stop offset="0%" stop-color="#08111f" />
7
+ <stop offset="100%" stop-color="#111b32" />
8
+ </linearGradient>
9
+ <filter id="shadow" x="-20%" y="-20%" width="140%" height="150%">
10
+ <feDropShadow dx="0" dy="8" stdDeviation="10" flood-color="#020617" flood-opacity="0.45" />
11
+ </filter>
12
+ <marker id="arrowhead" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">
13
+ <path d="M 0 0 L 6 3 L 0 6 Z" fill="#64748b" />
14
+ </marker>
15
+ <style>
16
+ .card { fill: #111c31; stroke: #334155; stroke-width: 1.5; filter: url(#shadow); }
17
+ .divider { stroke: #26364f; stroke-width: 1; }
18
+ .arrow { fill: none; stroke: #64748b; stroke-width: 2; }
19
+ .title { fill: #f8fafc; font: 700 30px Inter, ui-sans-serif, system-ui, sans-serif; }
20
+ .subtitle { fill: #94a3b8; font: 400 16px Inter, ui-sans-serif, system-ui, sans-serif; }
21
+ .step-number { fill: #08111f; font: 800 13px Inter, ui-sans-serif, system-ui, sans-serif; }
22
+ .step-title { fill: #f8fafc; font: 650 16px Inter, ui-sans-serif, system-ui, sans-serif; }
23
+ .step-copy { fill: #cbd5e1; font: 400 14px Inter, ui-sans-serif, system-ui, sans-serif; }
24
+ .footer { fill: #94a3b8; font: 500 15px Inter, ui-sans-serif, system-ui, sans-serif; }
25
+ .brand { fill: #475569; font: 600 13px Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: 0.08em; }
26
+ </style>
27
+ </defs>
28
+ <rect width="1200" height="360" rx="24" fill="url(#background)" />
29
+ <text x="32" y="48" class="title">TrendFollow</text>
30
+ <text x="32" y="78" class="subtitle">Pivot structure → ATR trail → directional regime change</text>
31
+ <text x="1168" y="48" text-anchor="end" class="brand">TRADEJS</text>
32
+ <g>
33
+ <rect x="32" y="120" width="192" height="150" rx="18" class="card" />
34
+ <rect x="32" y="120" width="192" height="6" rx="3" fill="#22d3ee" />
35
+ <circle cx="56" cy="148" r="13" fill="#22d3ee" />
36
+ <text x="56" y="153" text-anchor="middle" class="step-number">1</text>
37
+ <text x="79" y="154" class="step-title">Update pivots</text>
38
+ <path d="M 48 169 H 208" class="divider" />
39
+ <text x="50" y="197" class="step-copy">
40
+ <tspan x="50" dy="0">Replayable highs</tspan>
41
+ <tspan x="50" dy="22">Replayable lows</tspan>
42
+ </text>
43
+ </g>
44
+ <path d="M 224 195 H 254" class="arrow" marker-end="url(#arrowhead)" />
45
+ <g>
46
+ <rect x="268" y="120" width="192" height="150" rx="18" class="card" />
47
+ <rect x="268" y="120" width="192" height="6" rx="3" fill="#60a5fa" />
48
+ <circle cx="292" cy="148" r="13" fill="#60a5fa" />
49
+ <text x="292" y="153" text-anchor="middle" class="step-number">2</text>
50
+ <text x="315" y="154" class="step-title">Move trail</text>
51
+ <path d="M 284 169 H 444" class="divider" />
52
+ <text x="286" y="197" class="step-copy">
53
+ <tspan x="286" dy="0">ATR offset</tspan>
54
+ <tspan x="286" dy="22">Bounded state</tspan>
55
+ </text>
56
+ </g>
57
+ <path d="M 460 195 H 490" class="arrow" marker-end="url(#arrowhead)" />
58
+ <g>
59
+ <rect x="504" y="120" width="192" height="150" rx="18" class="card" />
60
+ <rect x="504" y="120" width="192" height="6" rx="3" fill="#f59e0b" />
61
+ <circle cx="528" cy="148" r="13" fill="#f59e0b" />
62
+ <text x="528" y="153" text-anchor="middle" class="step-number">3</text>
63
+ <text x="551" y="154" class="step-title">Detect flip</text>
64
+ <path d="M 520 169 H 680" class="divider" />
65
+ <text x="522" y="197" class="step-copy">
66
+ <tspan x="522" dy="0">Price crosses trail</tspan>
67
+ <tspan x="522" dy="22">Direction changes</tspan>
68
+ </text>
69
+ </g>
70
+ <path d="M 696 195 H 726" class="arrow" marker-end="url(#arrowhead)" />
71
+ <g>
72
+ <rect x="740" y="120" width="192" height="150" rx="18" class="card" />
73
+ <rect x="740" y="120" width="192" height="6" rx="3" fill="#c084fc" />
74
+ <circle cx="764" cy="148" r="13" fill="#c084fc" />
75
+ <text x="764" y="153" text-anchor="middle" class="step-number">4</text>
76
+ <text x="787" y="154" class="step-title">Qualify</text>
77
+ <path d="M 756 169 H 916" class="divider" />
78
+ <text x="758" y="197" class="step-copy">
79
+ <tspan x="758" dy="0">Structure + trend</tspan>
80
+ <tspan x="758" dy="22">Volume + benchmark</tspan>
81
+ </text>
82
+ </g>
83
+ <path d="M 932 195 H 962" class="arrow" marker-end="url(#arrowhead)" />
84
+ <g>
85
+ <rect x="976" y="120" width="192" height="150" rx="18" class="card" />
86
+ <rect x="976" y="120" width="192" height="6" rx="3" fill="#34d399" />
87
+ <circle cx="1000" cy="148" r="13" fill="#34d399" />
88
+ <text x="1000" y="153" text-anchor="middle" class="step-number">5</text>
89
+ <text x="1023" y="154" class="step-title">Manage trade</text>
90
+ <path d="M 992 169 H 1152" class="divider" />
91
+ <text x="994" y="197" class="step-copy">
92
+ <tspan x="994" dy="0">Trail stop</tspan>
93
+ <tspan x="994" dy="22">Opposite signal exit</tspan>
94
+ </text>
95
+ </g>
96
+ <text x="32" y="322" class="footer">Upward trail flip → LONG; downward trail flip → SHORT</text>
97
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/strategy-trend-follow",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "ATR trailing-trend strategy using pivot structure, optional breakout and benchmark filters, and trail or opposite-signal exits for TradeJS.",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@4.13.0",
@@ -29,7 +29,8 @@
29
29
  "module": "./dist/index.js",
30
30
  "types": "./dist/index.d.ts",
31
31
  "files": [
32
- "dist"
32
+ "dist",
33
+ "docs"
33
34
  ],
34
35
  "exports": {
35
36
  ".": {