TA-Lib.NETCore
TA-Lib.NETCore copied to clipboard
How to use the library
How to use the library. For example the Stochastic indicator.
public static RetCode Stoch ( double [] inHigh, double [] inLow, double [] inClose, int startIdx, int endIdx, double [] outSlowK, double [] outSlowD, out int outBegIdx, out int outNbElement, MAType optInSlowKMAType = MAType.Sma, MAType optInSlowDM .Sma, int optInFastKPeriod = 5, int optInSlowKPeriod = 3, int optInSlowDPeriod = 3);
The first three parameters (inHigh, inLow, inClose) are clear without explanation, but what the rest of the parameters (startIdx, endIdx, outSlowK, outSlowD, outBegIdx, outNbElement) mean is not clear.
You can give an example of use Stochatic.
Hi @hmG3, I also would love to know how to use this library. Can you point me to any example code to just do a Simple Moving Average or RSI for example.. Thanks! Is there a reference guide or WIKI that you can point me to?
Hi, for anyone trying to work this out, as there is no documentation that I could see, I thought I'd post a code snippet that is working for me. This successfully calculates a 21 EMA:
`
// Calculate EMA 21 period
var closesArray = closes.ToArray();
int outBegIdx = 0;
int outNbElement = 0;
double[] outarray = new double[closesArray.Count()-20];
try
{
TALib.Core.Ma(closesArray, 0, closesArray.Count()-1, outarray, out outBegIdx, out outNbElement, Core.MAType.Ema, 21);
}
catch (Exception ex)
{
Console.WriteLine($"exception calculating EMA 21: " + ex.Message);
}
var i = 0;
var outCount = 0;
foreach( FullMarketData dataItem in fullMarketData)
{
if (i >= outBegIdx)
{
dataItem.EMA21 = outarray[outCount];
Console.WriteLine($"{dataItem.Timestamp} - EMA8: { dataItem.EMA21 } Close: {dataItem.Close}");
outCount++;
} else
{
Console.WriteLine($"{dataItem.Timestamp} - no data");
}
i++;
}
`
Well, GitHub had a good run.