technicalindicators
technicalindicators copied to clipboard
Bullish vs Bearish indicators not checking Open vs Close
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
- it wasn't explicitly checking if open < close (definition of bearish in this case)
- 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 Sure provide a pull request. Make sure you update the test. Let me know if you face any issue setting up the workflow.
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!
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.
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 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
@kwhitley Did you ever get this PR together?