TA-Lib.NETCore icon indicating copy to clipboard operation
TA-Lib.NETCore copied to clipboard

How to use the library

Open avrezvanov opened this issue 4 years ago • 3 comments

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.

avrezvanov avatar Dec 29 '20 14:12 avrezvanov

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?

HollandRisley avatar Feb 20 '21 18:02 HollandRisley

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++;
        }

`

HollandRisley avatar Feb 21 '21 12:02 HollandRisley

Well, GitHub had a good run.

corysimmons avatar Feb 21 '24 01:02 corysimmons