Topics
Replies
Amaizing
04 May 2020, 12:18
RE:
PanagiotisCharalampous said:
Hi Stephan
If what you need is to add a reference of a dll to a cBot then do the following.
- Edit the cBot in VS
- Right click on References
- Choose "Add Reference..."
- In the pop up window, choose "Browse"
- Click on Browse, find your dll and add it
I hope this helps
Best Regards,
Panagiotis
Hi Panagiotis ,
Thank you for your help. I managed to make a dll in a new .NET project, but this was empty and step by step online tutorial. But when I try to make this dll for my cbot in VS it does not work, reference, gives errors and/or was not saved as dll.
I really need a step by step instruction, just to start with a empty bot and create a new dll.
@Amaizing
Amaizing
04 May 2020, 11:15
RE:
PanagiotisCharalampous said:
Hi Stephan,
There is nothing specific in cAlgo and cTrader for this. It works in the exact same way as any .Net project. To help you further, 'you need to provide us information on what error messages you receive and how to reproduce them.
Best Regards,
Panagiotis
Hi Panagiotis, I am familiar with building cBot and Indicators in the cTrader app but meanwhile I have so many supporting methods I want to bring them in a external class for which i was looking to do this with a .dll, however I am not experienced in Visual Studio. I've did some research online and tried to build tin in a .NET project but somewhere I need to reference the both source files (cbot and dll) to each other by code and some handlings in Visual Studio. Also I need to reference the dll in cTrader to the cBot. I just get stuck because somewhere as I just don't follow the right approach. With all things in life, it is easy as you know what to do. Therefore I kindly request if somebody can help me by sharing all the right steps and provide some working basic code. Thank you.
@Amaizing
Amaizing
04 May 2020, 14:27
RE:
PanagiotisCharalampous said:
Hi Panagiotis,
It is indeed not a cBot/cTrader issue and you can find tons of information about how to create a dll from a new .NET project in Visual Studio, however I cannot find anywhere a clear and whole instruction how to make this work for me in cTrader. Only how to reference a existing dll but before this i do first need to build a dll in VS. For this I do ask instructions on this forum.
Your post 14 Jan 2019, 10:35 was very helpful and lets take this as starting point.
In cTrader I create a new cBot and put here the next code:
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
protected override void OnStart()
{
Print(General.GetPosCnt(this));
Print(General.GetLastCloseValue(this));
}
protected override void OnBar()
{
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
This I cannot Build because the General does not exist in the current context, also i do not have a dll yet. So I start with a default bot, I Build this successfully and then Edit in Visual Studio, after which Visual Studio 2019 opens with the code. Here I can paste the above code. The 'cBots and Custom Indicators' extension I do have installed. Then what should I do next to create the dll based on the code below?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
namespace cAlgo
{
public class General
{
public static int GetPosCnt(Robot robot)
{
int iPosCnt;
iPosCnt = robot.Positions.Count;
return iPosCnt;
}
public static double GetLastCloseValue(Robot robot)
{
return robot.MarketSeries.Close.LastValue;
}
}
}
As last, how to reference them and make this work as a whole in cTrader?
Thank you in advance.
Kind regards,
Stephan
@Amaizing