This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:

We work extremely hard to keep things positive on our forums.

We do not tolerate rude behavior, trolling, or vendor advertising in posts.

We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.

We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

Thanks @gregid. My programming skills are still very basic and limited to what I have learned to do inside NT in the past 6 months. My question is when I download projects or libraries, what are the steps to being able to use them inside NT? Do I have to move the files to a certain location? Do I have to declare "using" statements? I appreciate all your help and I am trying to learn more in depth programming.

There are 2 options:
1) You can locate LibSharpTave.dll in the downloaded code for OctaveSharp. Then add reference to this file from your ninjascript (right click in the NinjaScript editor "References", "Add" then browse for the LibSharpTave.dll
2) You can locate Octave.cs file from source code and copy it to your Strategy or Indicator folder in NT. Compile some indicator/strategy

Whichever option you choose - you need to use the following statement:

using LibSharpTave;

The rest is just as in the snippet above. Please bear in mind I haven't tested it so I may have missed something, but I don't think so.

Obviously when you instantiate Octave you need to provide correct path

Good luck and let us know how are you doing!

The following user says Thank You to gregid for this post:

There are 2 options:
1) You can locate LibSharpTave.dll in the downloaded code for OctaveSharp. Then add reference to this file from your ninjascript (right click in the NinjaScript editor "References", "Add" then browse for the LibSharpTave.dll
2) You can locate Octave.cs file from source code and copy it to your Strategy or Indicator folder in NT. Compile some indicator/strategy

Whichever option you choose - you need to use the following statement:

using LibSharpTave;

The rest is just as in the snippet above. Please bear in mind I haven't tested it so I may have missed something, but I don't think so.

Obviously when you instantiate Octave you need to provide correct path

Good luck and let us know how are you doing!

Thanks for this information. I just started going through the Octave Manual page by page, and should be able to start using it by next week. Would tick by tick calculations take too long with C# and a standard PC? I don't want to start experimenting with tick data just to find out any reasonably priced setup would be too slow, or that NT running on C# would be too slow.

Thanks for this information. I just started going through the Octave Manual page by page, and should be able to start using it by next week. Would tick by tick calculations take too long with C# and a standard PC? I don't want to start experimenting with tick data just to find out any reasonably priced setup would be too slow, or that NT running on C# would be too slow.

I have adapted the OctaveSharp from CodeProject to .NET 3.5 for NT7 and so it doesn't need a DLL which looked like it would be .NET 4.0 and NT7 would not load it. I have also added some features and the ability to maintain a single copy of Octave per strategy. Without the changes you could end up with many copies of Octave running in the background.

The Strategy has example code on sending Matrix's and receiving Scalar's, Vector's, and Matrix's. Also how to access the matrix values.

This approach does use Standard output so keep in mind the logic will want to use it to minimize IO size. Create a way to append to arrays and only import data you need.

There are a few major sections (In Startup)
m_Octave=new Octave(m_OctavePath,false); // Makes the connection to Octave
m_Octave.ExecuteCommand("a=[1,2,3,4,5,6,7,8,9,10];");
m_Octave.ExecuteCommand("b=[11,21,31,41,51,61,71,81,91,101];");
m_Octave.ExecuteCommand("aa=[a;b];");
OnBarUpdate:
m_Octave.ExecuteCommand("c=["+CurrentBar+","+(CurrentBar+1)+","+(CurrentBar+2)+
","+(CurrentBar+3)+","+(CurrentBar+4)+","+(CurrentBar+5)+
","+(CurrentBar+6)+","+(CurrentBar+7)+","+(CurrentBar+8)+","+(CurrentBar+9)+"];");
// Creates a vector "c" of the current bar with offset depending on depth in vector
m_Octave.ExecuteCommand("scalar=c(9);");
// scalar is set to the 9th element of "c" (starting index in Octave is 1 not 0)

m_Octave.ExecuteCommand("m=a.+b.+c");
// Dot wise addition
m_Octave.ExecuteCommand("aa=[a;b;m];");
// Creates a 3x10 matrix by combining the row vectors into a matrix

//Get the Scalar, Vector, & Matrix values from Octave back into C# val = m_Octave.GetScalar("scalar");
double [] a = m_Octave.GetVector("a");
double [] b = m_Octave.GetVector("b");
double [] c = m_Octave.GetVector("c");
double [] m = m_Octave.GetVector("m");
double [][] aa = m_Octave.GetMatrix("aa");

Here is a sample run from the strategy (Print statements in Strategy):

Bear with me guys, I haven't looked at this level mathematics in over 6 years. Could someone post a simple example of finding the least squares solution of a system of linear equations, returning the solution and the residual matrix?

Bear with me guys, I haven't looked at this level mathematics in over 6 years. Could someone post a simple example of finding the least squares solution of a system of linear equations, returning the solution and the residual matrix?

I think you truly need to return the value into the matrix as shown:
[beta, sigma, r] = ols (y, x)

I think this is how multiple parameters are returned. You will then get beta, sigma, & r set from the OLS function.

I will have to try that when I get home. FYI I think this function is too slow calculate on a tick by tick basis. The simple example above took about .5 sec on my laptop(no the greatest laptop).