Resources for Creating Custom DLL?

24 Oct 2013, 09:23Resources for Creating Custom DLL?#1
Hyperloopposts: 87since: 23 Oct 2013

HI,

I'm wondering if anyone has examples/resources about writing custom DLLs for cAlgo. 

I would like to compile a library of commonly used methods so I can develop robots/indicators faster. 

Thanks!

24 Oct 2013, 09:26RE:#2
Hichem posts: 121since: 17 Dec 2012

To develop a .dll in visual studio import the cAlgo.API.dll in your project.

After compiling the .dll with Visual Studio you can import it in cAlgo by clicking add Reference, and select the .dll you created.

 

 

Hyperloop said:

HI,

I'm wondering if anyone has examples/resources about writing custom DLLs for cAlgo. 

I would like to compile a library of commonly used methods so I can develop robots/indicators faster. 

Thanks!

 

24 Oct 2013, 20:52#3
Hyperloopposts: 87since: 23 Oct 2013
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;

namespace PBLibrary
{
    public class stdFun
    {
        // Generate Label function
        // string InstanceID = GenerateLabel("123", "1");
        private string GenerateLabel(string argStrategyID, string argVersionID)
        {
            string FinalLabel = argStrategyID + "-" + argVersionID + "-" + Symbol.Code + "-" + TimeFrame.ToString();
            return FinalLabel;
        }
    }
}

Error    1    An object reference is required for the non-static field, method, or property 'cAlgo.API.Internals.Symbol.Code.get'    C:\Users\Clark\Documents\Visual Studio 2010\Projects\PBLibrary\PBLibrary\Class1.cs    15    76    PBLibrary
Error    2    An object reference is required for the non-static field, method, or property 'object.ToString()'    C:\Users\Clark\Documents\Visual Studio 2010\Projects\PBLibrary\PBLibrary\Class1.cs    15    96    PBLibrary

I'm currently getting this error when I am trying to build this library. When simply copied and pasted this method into a Robot it would run fine. I'm a little new to C# so any help would be appreciate.

24 Oct 2013, 23:01RE:#4
Hichem posts: 121since: 17 Dec 2012

The Symbol object is a property of the Robot class. It is undefined inside your stdFun class

 

Hyperloop said:

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;

namespace PBLibrary
{
    public class stdFun
    {
        // Generate Label function
        // string InstanceID = GenerateLabel("123", "1");
        private string GenerateLabel(string argStrategyID, string argVersionID)
        {
            string FinalLabel = argStrategyID + "-" + argVersionID + "-" + Symbol.Code + "-" + TimeFrame.ToString();
            return FinalLabel;
        }
    }
}

Error    1    An object reference is required for the non-static field, method, or property 'cAlgo.API.Internals.Symbol.Code.get'    C:\Users\Clark\Documents\Visual Studio 2010\Projects\PBLibrary\PBLibrary\Class1.cs    15    76    PBLibrary
Error    2    An object reference is required for the non-static field, method, or property 'object.ToString()'    C:\Users\Clark\Documents\Visual Studio 2010\Projects\PBLibrary\PBLibrary\Class1.cs    15    96    PBLibrary

I'm currently getting this error when I am trying to build this library. When simply copied and pasted this method into a Robot it would run fine. I'm a little new to C# so any help would be appreciate.

 

25 Oct 2013, 22:20#5
Hyperloopposts: 87since: 23 Oct 2013

Hi, 

Thanks for all your help. I'm still a little confused, could you kindly provide an example code so I know what you mean?

Thanks again. :)

29 Oct 2013, 11:11Library of Trading Tools#6
BestFXBotposts: 7since: 07 Oct 2013

This article explains how  import the cAlgo.API.dll in your project. - http://carbonfx.io/2013/08/using-visual-studio-with-calgo/

Once you make the necessary links, you can start building different tools for your projects and import these functions through

using CarbonFx.Utilities; // example


 

29 Oct 2013, 21:33RE: Library of Trading Tools#7
Hyperloopposts: 87since: 23 Oct 2013

BestFXBot said:

This article explains how  import the cAlgo.API.dll in your project. - http://carbonfx.io/2013/08/using-visual-studio-with-calgo/

Once you make the necessary links, you can start building different tools for your projects and import these functions through

using CarbonFx.Utilities; // example
 

Thank you very much, I'll give it a shot. :)

05 Jan 2014, 13:05Better Support for DLL and cAlgo in Visual Studio#8
PCWalkerposts: 21since: 19 Nov 2012

Is there any progress in the development of Visual Studio developments for cAlgo?

Thank you.

07 Jan 2014, 10:56RE: Better Support for DLL and cAlgo in Visual Studio#9
cTrader Teamposts: 3391since: 23 Sep 2013

PCWalker said:

Is there any progress in the development of Visual Studio developments for cAlgo?

Thank you.

Please see /forum/calgo-support/1333?page=2#11


TRADERS FIRST™ Vote for your favorite features: http://vote.spotware.com/
10 Mar 2014, 18:53#10
AimHigherposts: 24since: 04 Jan 2014

I am having the same problem as Hyperloop and since I am also new to C#, setting the correct references and objects is still hit or miss for me. As I believe Hyperloop was trying to do, I am trying to create a dll to hold methods that I will use in different robots. I have created other dlls that are working fine but I am struggling with using cAlgo,API in my custom dll.

I am working in VS 2010. I have added cAlgo.API in References (for this project) so I get IntelliSense and I can view it fine through the Object Browser. I also have no problem using VS2010 to write cBots in general. That part is working great. It is creating a custom dll that uses cAlgo.API dll that has me stomped.

The code I have so far for my custom dll is this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;

namespace cAlgoGeneralMethods
{
    public class General
    {
        private int GetPosCnt()
        {
        	int iPosCnt;
	        iPosCnt = Positions.Count;
        	return iPosCnt;
        }
    }
}

As anyone who knows C# (I don't) the line 

iPosCnt = Positions.Count; will not work and I would get the same error as Hyperloop got.

I have looked at the responses that Hyperloop got but I have not found a specific example of how to get it to work. I would very much appreciate a quick sample of what I need to add to get cAlgo.API objects/methods recognized in my custom dll.

Regards,

Aim