Can't add .dll reference to my cBot
19 Jan 2016, 13:11
Hi,
I'm trying to add external library for matrix manipulation and calculations ( Math.NET); however for some reason cAlgo does not recognise that I have referenced the library.
using cAlgo.API.Internals; using cAlgo.Indicators; using MathNet.Numerics.LinearAlgebra; using MathNet.Numerics.LinearAlgebra.Double;
When building I get following error
Error CS0246: The type or namespace name 'MathNet' could not be found (are you missing a using directive or an assembly reference?)
I add references to the bot through 'Manage References' button.
Could you give me some possible solution to this problem?
Many thanks
Replies
stasiek.abyszkin
19 Jan 2016, 16:52
Hi,
Yes I have. I already solved the problem, I was referencing the wrong library through the Reference Manager.
Sorry for troubling you.
Many thanks
@stasiek.abyszkin
gutygs
25 Jul 2019, 17:25
Hello!
I am having the same problem yet I can't find a way to fix it.
I'm trying to reference the NumSharp library in my code. To do that, I downloaded the package via NuGet on VisualStudio and I followed the steps on the link to point to the downloaded .dll
The program seems to compile just fine when I use the statement
using NumSharp;
nonetheless, when I try to use any of the many classes from the package, I get a compilation error. For instance, when trying to use
var nd = np.arange(12);
which is a statement that's perfectly fine on VisualStudio when using Numsharp, in cTrader I get several errors point that System.object .ICloneable .Collections.IList etc are defined on an assembly that is not referenced, and that I must add a reference to assembly netstandard.
I know this is probably not the correct way to get the Library, but there's no other way, and since I can't interact with Visual Studio, I am left with no other choice but to point to the library like this.
Is there any way to work around this?
Thank you very much!
@gutygs
PanagiotisCharalampous
25 Jul 2019, 17:27
Hi gutygs,
Can you please post a link to the NuGet package and the cBot code you are using?
Best Regards,
Panagiotis
@PanagiotisCharalampous
gutygs
25 Jul 2019, 18:36
Sure thing!
This is the package I'm trying to install:
https://www.nuget.org/packages/NumSharp/
And this is the code that I'm trying to build:
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using NumSharp;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Strategy5 : Robot
{
[Parameter("iCandle", DefaultValue = 7)]
public int iCandle { get; set; }
protected override void OnStart()
{
Print("initializing console");
}
protected override void OnBar()
{
//lets print the last 7 candle closes
Print("Printing the last 7 candles");
var lastIndex = MarketSeries.Close.Count - 2;
//start from -2 because -1 corresponds to current candle price
Print(lastIndex);
//Define the dataseries arrays
double[] closePrices = new double[iCandle];
double[] openPrices = new double[iCandle];
double[] highPrices = new double[iCandle];
double[] lowPrices = new double[iCandle];
//Fill the dataseries arrays with data
for (int i = 0; i < iCandle; i++)
{
double close = MarketSeries.Close[lastIndex - i];
double open = MarketSeries.Open[lastIndex - i];
double high = MarketSeries.High[lastIndex - i];
double low = MarketSeries.Low[lastIndex - i];
closePrices[iCandle - 1 - i] = close;
openPrices[iCandle - 1 - i] = open;
highPrices[iCandle - 1 - i] = high;
lowPrices[iCandle - 1 - i] = low;
}
var nd = np.arange(12); //error on this line
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
I installed the package in another project in Visual Studio by using the NuGet command line via
PM> Install-Package NumSharp
and pointed back on cTrader, pointed to the dll as showin in the tutorial here: https://ctrader.com/api/guides/referencing_dll
The reason I want to install this package is because I need to perform matrix operations with tensors, and back when using python, I mainly used Numpy.
Thanks for the help!!
@gutygs
PanagiotisCharalampous
26 Jul 2019, 09:28
Hi gutygs,
The reason is that this package is built using a .Net framework version higher than 4.0. At the moment the supported framework for cTrader Automate is v4.0.
Best Regards,
Panagiotis
@PanagiotisCharalampous

Spotware
19 Jan 2016, 13:45
Dear Trader,
Have you performed the exact steps described in the Referencing a dll section of our API Guides?
@Spotware