Looking for code that draws trend lines or linear regression lines (preferably in C#)

Quote from Newmoney24:

If you can link me to them I would be grateful,
I don't know if there's multiple versions of it and if any are better than others as I don't currently use ninjatrader

Go to www.ninjatrader.com and download the software..

look in:

\My Documents\NinjaTrader 7\bin\Custom\Indicator


there you have all of their indicators in .cs file format
 
Quote from Newmoney24:

As title says, I want a code that takes a stock ticker data and finds/draws a linear regression line or draws a trendline connecting the lows (or the highs)
Anyone know of or have some of this data developed?

You might want to Goggle (image) 'automatic trend line' to see some results of what others have done. Seeing that,
you might want to reconsider and draw the lines yourself.

If you click on some of the images, it'll take you to where you can download the code.

Hope you find something that really works.
 
i am bumping this to see if anyone has ideas to add, I got a bit of code from a previous poster but do not feel it's sufficient,

appreciate the help so far
 
Quote from Newmoney24:

i am bumping this to see if anyone has ideas to add, I got a bit of code from a previous poster but do not feel it's sufficient,

appreciate the help so far


"It's sooo basiccc, but I can't do it, can someone give it to me for free?"- is all I read. Maybe if you attach some monetary benefit in solving your problem you would get more proper responses.
 
Quote from patrickmcmichae:

function BestFit(const AnArray: array of Double): Extended;
var n: Integer;
b,m: Double;
begin
n := Length(AnArray);
b := BestFitB(AnArray);
m := BestFitM(AnArray);
Result := b + (m * n);
end;

function BestFitLn(const AnArray: array of Double): Extended;
var n: Integer;
b,m: Double;
begin
n := Length(AnArray);
b := BestFitB(AnArray);
m := BestFitM(AnArray);
Result := b + (m * (n+1));
end;

function BestFitM(const AnArray: array of Double): Extended;
var n,i: Integer;
summation,m: Double;
begin
n := Length(AnArray);
summation := 0;
for i := 1 to n do summation := summation + (AnArray[i-1] * i);
m := ((12/(Power(n,3)-n))*summation) - ((6/(Sqr(n)-n))*Sum(AnArray));
Result := m;
end;

function BestFitB(const AnArray: array of Double): Extended;
var n,i: Integer;
summation,b: Double;
begin
n := Length(AnArray);
summation := 0;
for i := 1 to n do summation := summation + (AnArray[i-1] * i);
b := ((((4*n)+2)/(Sqr(n)-n))*Sum(AnArray)) - ((6/(Sqr(n)-n))*summation);
Result := b;
end;



I appreciate this but it is incomplete as I can't use it without plugging data into it, where is the code for that?


ie: I need to be able to direct it to an excel sheet or ASCII with the data
(where the layout of my data is as follows:

"Date","Time","Open","High","Low","Close","Volume"
06/28/2004,0931,37.49,37.50,37.45,37.46,1049200
 
Quote from Newmoney24:

I appreciate this but it is incomplete as I can't use it without plugging data into it, where is the code for that?


ie: I need to be able to direct it to an excel sheet or ASCII with the data
(where the layout of my data is as follows:

"Date","Time","Open","High","Low","Close","Volume"
06/28/2004,0931,37.49,37.50,37.45,37.46,1049200


----and moreso for it to go through a folder with these ASCII files and do it for each one


Learn to program
 
Back
Top