technicalindicators icon indicating copy to clipboard operation
technicalindicators copied to clipboard

Bullish vs Bearish indicators not checking Open vs Close

Open kwhitley opened this issue 7 years ago • 6 comments

For instance, bearishspinningtop returns true for the following data

low: [205],
high: [207.95],
open: [206.16],
close: [207.9],
volume: [5231.61]

I noticed a couple things in the following code:


let bodyLength           = Math.abs(daysClose-daysOpen); // this is good
let upperShadowLength    = Math.abs(daysHigh-daysOpen); // this should be daysHigh - Math.max(daysOpen, daysClose)
let lowerShadowLength    = Math.abs(daysHigh-daysLow); // this should be Math.min(daysOpen,days.close) - daysLow
let isBearishSpinningTop = bodyLength < upperShadowLength &&
  bodyLength < lowerShadowLength; // this should include check for daysClose < daysOpen

  1. it wasn't explicitly checking if open < close (definition of bearish in this case)
  2. the shadow calculations were off (comments in code above)

Would you like me to start a PR to go through and fix these? I'm very interested in getting all these working for my project and would prefer to contribute to your lib rather than fork to correct.

kwhitley avatar Jul 13 '17 20:07 kwhitley

@kwhitley Sure provide a pull request. Make sure you update the test. Let me know if you face any issue setting up the workflow.

anandanand84 avatar Jul 13 '17 21:07 anandanand84

Will do @anandanand84

As to the work environment, I needed to run the following (OSX) before npm install would complete successfully:

brew install cairo
xcode-select --install

...and to fully install (to run npm test)

npm install --save-dev draw-candlestick@^1

These will be included in the README update with the PR if you don't mind!

kwhitley avatar Jul 14 '17 03:07 kwhitley

Also, should I be working on the .ts files in /src or the .js files in /lib? I don't see a script in the package.json to transpile TypeScript into the lib folder (where the tests are being run from), and am generally unfamiliar with TypeScript dev/build processes.

kwhitley avatar Jul 14 '17 03:07 kwhitley

Nevermind, read some TS docs and will add that step to the README as well:

# install typescript
npm install -g typescript

# run typescript within project to build from ./src to ./lib for testing
tsc

kwhitley avatar Jul 14 '17 04:07 kwhitley

@kwhitley sorry for the late reply. glad you figured that out. I would recommend vscode https://code.visualstudio.com vscode come with typescript support so you dont have to run the tsc command every time and I missed the draw-candlestick and cairo installation part which are necessary for developement that gives you the image of the test data so it is easy to develop new patterns. It would be helpfull if you add it to the readme along with pr. Thanks

anandanand84 avatar Jul 14 '17 04:07 anandanand84

@kwhitley Did you ever get this PR together?

JMoli avatar Apr 05 '18 09:04 JMoli