-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
CalculateInsyncIndex throws the following exception #43
Comments
@HamzaAhmedZia7 This error is by design since the Bollinger Bands are one of the few indicators that doesn't output a single value but outputs 3 values (High band, Middle band, and Low band), and if you were to calculate an indicator based on this output, you would need to specifically select one of the bands using the OutputValues Dictionary instead of using the CustomValuesList object. I will be including a test project where you can try out some of these options and hopefully it will make things easier for the average user. Let me know if you need an example |
LazyBear makes use of both upper and lower bands if I'm not mistaken
and then uses bolinsll in the final calculation
then why should I need to specifically select one?
I have not read your code...do you not take into account the upper and the lower bands? Then will the iidx values be consistent with what is on tradingview? A Test project and example ... yes please. |
…inger Bands method #43 Made some minor changes for better code readability
@HamzaAhmedZia7 I will add the test project later but I did see the reason for the exception and provided a fix so if you can please get the latest and confirm that it works now |
I have sourced the data for this stock from TradingView website so there should be no discrepencies |
@HamzaAhmedZia7 Well in this case, feel free to take a look at my bollinger band code and see if you spot any issues |
In method public static StockData CalculateStandardDeviationVolatility(this StockData stockData, MovingAvgType maType = MovingAvgType.SimpleMovingAverage, int length = 20) which is called from CalculateBollingerBands(); the item is being set to the moving average list and not the close price/inputList therefore there is an error I do not know how to edit and fix nuget packages. I tried doing the following change however while debugging VS always picks up your nuget package. Wasted an hour trying to debug with my changes in vain.
I cannot investigate further since I cannot change nuget source code or maybe I do not know how to.... Hopefully this will take you in the right direction. Also there are straight forward ways of calculating std deviations. Why have you taken such a convoluted approach.
I would highly recommend not to reinvent the wheel and use one of the better open source math libraries Math.NET
|
@HamzaAhmedZia7 A couple of things I need to clarify with you. I do my own standard deviation calculation because it is used as a stock indicator and is also used by multiple technical analysis calculations and the code you posted above will fail since it doesn't handle potential errors like doing a square root for a negative number or checking that the values list has items for example. You can view the full source code for my library by going to the main code tab and click on the green code button that will allow you to download my full source code. I have no clue what you mean about it being set to the moving average list and not using the input list so you will need to elaborate on that. |
Obviously I wasn't trying to fully understand the architectural decisions you took and the reasons for using such a round about method. I just wanted to check for a quick fix. If it had worked I would have pointed out the trivial resolution for you to elaborately fix it. ;-)
Checking for these are trivial
In function CalculateStandardDeviationVolatility which is called from CalculateBollingerBands(); Therefore, the next line calculates the simple moving average of the simple moving average instead of the close prices. I presume you are trying to set item to the list of close prices for the security. That is discrepency I found and after that being a nuget package could not go further. Hope this points you to the right direction.
Possibly some other time |
Greetings Franklin,
This code
produces this exception
in method CalculateDetrendedPriceOscillator at line CalculationsHelper.GetInputValuesList(stockData).inputList;
It is called by this code
I am trying out your excellent humongous library. :-)
The text was updated successfully, but these errors were encountered: