-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempted to fix the Projection Upper band and lower band calculation #329
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #329 +/- ##
==========================================
+ Coverage 64.64% 66.00% +1.36%
==========================================
Files 93 93
Lines 1533 1562 +29
Branches 183 186 +3
==========================================
+ Hits 991 1031 +40
+ Misses 529 518 -11
Partials 13 13
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Hi @cinar , I was wondering if you got a chance to have a look at the previous comment and the code? Regards, |
My sincere apologies, I totally missed your earlier message. Let me quickly take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added few comments. Thank you very much for your contribution!
@@ -22,15 +24,31 @@ export interface ProjectionOscillator { | |||
spo: number[]; | |||
} | |||
|
|||
// Just pads a number array with zeros to the right so that the length of the arr becomes desiredLength | |||
function padWithZeros(desiredLength: number, arr: number[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice helper function to add to ../../helper/numArray probably?
const arr_period: number[] = generateNumbers(0, period, 1); | ||
const pu = new Array(closings.length); | ||
for (let i = 0; i < highs.length; i++) { | ||
// for (let j = 0; j < period; j++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove these comments?
|
||
const pl = new Array(closings.length); | ||
for (let i = 0; i < lows.length; i++) { | ||
// for (let j = 0; j < period; j++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove these comments?
|
||
const pu = mmax(period, vHighs); | ||
const pl = mmin(period, vLows); | ||
// const pu = mmax(period, vHighs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove these comments?
return result; | ||
} | ||
|
||
const closings = generateRandomNumbers(100, 30, 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess some test code got left over here?
return mean + stdDev * (Math.random() - 0.5); | ||
} | ||
|
||
function generateRandomNumbers(count: number, mean: number, stdDev: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be the function can be named differently to reflect how you are using the mean and stdDev? I guess they are not just random number right? Also would be nice to have this in ../../helper/numArray.ts as well.
const highs = addBy(0.5, closings); | ||
const lows = subtractBy(0.5, closings); | ||
|
||
const result = projectionOscillator(14, 5, highs, lows, closings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have a test case here, can we put it into the unit test?
So @cinar , does the changes in the logic part make sense. Does the error in the previous version of the code and my fix make logical sense, or do you have any questions about it. Yes I will clean up the file, I just wanted to first confirm if the logic is right 😅 . Also is there some way to check if this implementation is actually giving the right values? |
I think your fix definitely makes sense. What we are lacking is a test case here. If we can find a source of truth for this calculation that we can compare the results against, it will give us more confidence that this is the correct algorithm to go with. Not sure if there is already an example that we can use, or an other tool to compute and compare the results against? |
Attempting to fix #218
Modified the projection Oscillator function by changing the calculation of the arrays
pu
andpl
according to what I suspect the issue is, as I mentioned in the conversation of #218Hi @cinar ,
Please have a look at the code which has
LOOK HERE
written, that is the changes made to the implementation mainly.Let me know what you think about it.
The file is messy right now, I will clean it after you have approved the changes in the logic part of the code.
I also needed advice on how I can test this indicator.
Thanks