Convert mlq4 to .js

Completed

Comments

3 comments

  • jeshayle singh

    Or if the Tradovate team could add this indicator to their library it would be great.

    0
    Comment actions Permalink
  • jeshayle singh

    This is the c# code for this indicator

    using cAlgo.API;

    namespace cAlgo
    {
        /// <summary>
        /// Linear Regression
        /// </summary>
        [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
        public class LinearRegression : Indicator
        {
            [Parameter()]
            public DataSeries Source { get; set; }

            [Parameter(DefaultValue = 14)]
            public int Period { get; set; }

            [Output("Main")]
            public IndicatorDataSeries Result { get; set; }

            public override void Calculate(int index)
            {
                double sumX = 0, sumY = 0, sumXY = 0, sumXPower = 0;

                for (int i = 0; i < Period; i++)
                {
                    sumXPower += i * i;
                    sumX += i;
                    sumY += Source[index - i];
                    sumXY += i * Source[index - i];
                }

                Result[index] = (sumXPower * sumY - sumX * sumXY) / (sumXPower * Period - sumX * sumX);
            }
        }


    0
    Comment actions Permalink
  • Tiki Dave

    Aloha! Just letting you know that I coded this up and it's available!  It's called the "Tiki Linear Regression Curve" in the code explorer. 

    See this post for more details: https://tradovate.zendesk.com/hc/en-us/community/posts/115009396428-Linear-Regression-Forecast-Indicator

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk