Start trading

c# to .js

Created at 31 Oct 2017
cTrader Reddit
cTrader Discord
JS

JS1979

Joined 02.02.2017

Status

Open


Budget

50.00 USD


Payment Method

Direct Payment

Job Description

Hi does anyone know how to convert c# into javascript or can create a .js indicator if given a c# code.

It is for the  Linear Regression Forecast indicator in cTrader. I want to use it on my other platform that codes in .js

I also have the mlq4 (mt4) code available if it helps.

Here is the c# code below.

Regards

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

Comments
Log in to add a comment.
nakw's avatar
nakw · 8 years ago

hi .. i am C#  / js,nodeJS  coder and i can do it

 

skype: dleeq8