Skip to content

Commit 9d09166

Browse files
committed
test: cover divergence contract aliases
1 parent 57ced83 commit 9d09166

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

tests/rsi-divergence-entry-alignment.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { presets } from "../lib/presets";
44

55
const clone = <T,>(value: T): T => JSON.parse(JSON.stringify(value));
66

7-
describe("RSI Divergence Reversal entry alignment", () => {
7+
describe("RSI divergence entry alignment", () => {
88
it("uses the same regular divergence events for pane labels and entries", () => {
99
const preset = presets.find((item) => item.name === "RSI Divergence Reversal");
1010
expect(preset).toBeDefined();
@@ -13,15 +13,29 @@ describe("RSI Divergence Reversal entry alignment", () => {
1313
config.outputMode = "indicator";
1414
const code = compilePine(config);
1515

16-
expect(code).toContain("longSetup = rsiValue >= rsiLongLevel and divRegularBullAlert and confirmationOk");
17-
expect(code).toContain("shortSetup = rsiValue <= rsiShortLevel and divRegularBearAlert and confirmationOk");
16+
expect(code).toContain("bullishDivergence = divRegularBullAlert");
17+
expect(code).toContain("bearishDivergence = divRegularBearAlert");
18+
expect(code).toContain("longSetup = rsiValue >= rsiLongLevel and bullishDivergence and confirmationOk");
19+
expect(code).toContain("shortSetup = rsiValue <= rsiShortLevel and bearishDivergence and confirmationOk");
1820
expect(code).not.toContain("pricePivotLow = ta.pivotlow(low, 5, 5)");
19-
expect(code).not.toContain("bullishDivergence =");
2021
expect(code.indexOf("// === Integrated RSI divergence pane ===")).toBeLessThan(
2122
code.indexOf("// === Filters and triggers ===")
2223
);
2324
});
2425

26+
it("aligns any supported indicator configuration when divergence is enabled", () => {
27+
const preset = presets.find((item) => item.name === "Balanced Intraday");
28+
expect(preset).toBeDefined();
29+
30+
const config = clone(preset!);
31+
config.outputMode = "indicator";
32+
config.momentum.divergenceEnabled = true;
33+
const code = compilePine(config);
34+
35+
expect(code).toContain("bullishDivergence = divRegularBullAlert");
36+
expect(code).toContain("bearishDivergence = divRegularBearAlert");
37+
});
38+
2539
it("does not change the strategy output path", () => {
2640
const preset = presets.find((item) => item.name === "RSI Divergence Reversal");
2741
expect(preset).toBeDefined();

0 commit comments

Comments
 (0)