Skip to content

Commit

Permalink
Improved cross up and down (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
srcmayte authored Nov 19, 2024
1 parent 51518a4 commit 4daefd6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/facts/ta/crossDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CrossDown extends Fact {
return false
}

const remaining = series1.slice(lastCrossIndex, series1.length)
const remaining = series1.slice(lastCrossIndex + 1, series1.length)

if (params.confirmationCountMin !== 0 && remaining.length < params.confirmationCountMin) {
return false
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/ta/crossUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CrossUp extends Fact {
return false
}

const remaining = series1.slice(lastCrossIndex, series1.length)
const remaining = series1.slice(lastCrossIndex + 1, series1.length)

if (params.confirmationCountMin !== 0 && remaining.length < params.confirmationCountMin) {
return false
Expand Down
8 changes: 4 additions & 4 deletions test/facts/ta/crossDown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('Fact ta.crossDown', () => {
})
})

describe('and amount of values after (and including) cross under is less than confirmationCountMin', () => {
describe('and amount of values after cross under is less than confirmationCountMin', () => {
it('returns false', async () => {
const result = await fact.value({
series1: [5, 5, 4, 2, 1],
Expand All @@ -196,7 +196,7 @@ describe('Fact ta.crossDown', () => {
})
})

describe('and amount of values after (and including) cross under is greater than or equal to confirmationCountMin', () => {
describe('and amount of values after cross under is greater than or equal to confirmationCountMin', () => {
it('returns true', async () => {
const result = await fact.value({
series1: [5, 5, 4, 2, 1],
Expand All @@ -222,7 +222,7 @@ describe('Fact ta.crossDown', () => {
})
})

describe('and amount of values after (and including) cross under is greater than confirmationCountMax', () => {
describe('and amount of values after cross under is greater than confirmationCountMax', () => {
it('returns false', async () => {
const result = await fact.value({
series1: [5, 4, 3, 2, 1],
Expand All @@ -234,7 +234,7 @@ describe('Fact ta.crossDown', () => {
})
})

describe('and amount of values after (and including) cross under is less than or equal to confirmationCountMax', () => {
describe('and amount of values after cross under is less than or equal to confirmationCountMax', () => {
it('returns true', async () => {
const result = await fact.value({
series1: [5, 4, 3, 2, 1],
Expand Down
14 changes: 7 additions & 7 deletions test/facts/ta/crossUp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('Fact ta.crossUp', () => {
})
})

describe('and amount of values after (and including) cross over is less than confirmationCountMin', () => {
describe('and amount of values after cross over is less than confirmationCountMin', () => {
it('returns false', async () => {
const result = await fact.value({
series1: [1, 1, 2, 4, 6],
Expand All @@ -193,7 +193,7 @@ describe('Fact ta.crossUp', () => {
})
})

describe('and amount of values after (and including) cross over is greater than or equal to confirmationCountMin', () => {
describe('and amount of values after cross over is greater than or equal to confirmationCountMin', () => {
it('returns true', async () => {
const result = await fact.value({
series1: [1, 1, 2, 4, 6],
Expand All @@ -219,24 +219,24 @@ describe('Fact ta.crossUp', () => {
})
})

describe('and amount of values after (and including) cross over is greater than confirmationCountMax', () => {
describe('and amount of values after cross over is greater than confirmationCountMax', () => {
it('returns false', async () => {
const result = await fact.value({
series1: [1, 1, 2, 4, 6],
series2: [1, 1, 2, 3, 4],
series1: [1, 1, 2, 4, 6, 7],
series2: [1, 1, 2, 3, 4, 5],
confirmationCountMax: 1
})

expect(result).to.eql(false)
})
})

describe('and amount of values after (and including) cross over is less than or equal to confirmationCountMax', () => {
describe('and amount of values after cross over is less than or equal to confirmationCountMax', () => {
it('returns true', async () => {
const result = await fact.value({
series1: [1, 1, 2, 4, 6],
series2: [1, 1, 2, 3, 4],
confirmationCountMin: 2
confirmationCountMax: 2
})

expect(result).to.eql(true)
Expand Down

0 comments on commit 4daefd6

Please sign in to comment.