Topics
Replies
driftingprogrammer
18 Aug 2020, 12:45
( Updated at: 15 Jan 2024, 14:51 )
I have added a feature request -
@driftingprogrammer
driftingprogrammer
18 Aug 2020, 12:44
( Updated at: 18 Aug 2020, 14:01 )
Backtest are innacurate because they do not take into account swaps.
This feature is very much required to make backtest accurate.
@driftingprogrammer
driftingprogrammer
03 Jul 2020, 17:05
Move to suggestions
Hi Admin,
I was meaning to put this post under suggestions, not sure how it landed here and now I cannot delete it or move it.
Thanks.
@driftingprogrammer
driftingprogrammer
03 Jul 2020, 16:00
RE:
solark said:
This version might be a bit quicker this time around....
cbotfile is just an ini file (open one in a text editor).
So for example (sorry dont use C# often) you could do
var l = new List<string>(); l.Add("[ChartParameters]"); l.Add("Symbol = " + this.Symbol.Code); l.Add("Timeframe = " + this.TimeFrame); l.Add("[cBotParameters]"); foreach (var p in this.GetType().GetProperties().Where(x => x.GetCustomAttributes(typeof(ParameterAttribute), false).Length > 0).Select(x => string.Format("{0} = {1}", x.Name, x.GetValue(this)))) { l.Add(p); } System.IO.File.WriteAllLines("mycbotsetfile.cbotset", l);
If you're creating a Dump method then one parameter would be `this`.
Some useful things to log:
- this.History, I just save to a csv
- StartTime: r.MarketSeries.OpenTime.[0].ToString("o")
- EndTime: r.MarketSeries.OpenTime.LastValue.ToString("o")
- ExperimentTime. DateTime.Not.ToString("o")
- RunTime: this would require a method call OnStart and tracking a "Dump" object (maybe not worth it). I just use System.Diagnostics.StopWatch
- Assembly Name/Location
var a = System.Reflection.Assembly.GetExecutingAssembly(); a.AssemblyName; a.Location;- Using the assembly location you should beable to copy the cs file that created it
- Market data history: This makes things take longer and really starts to eat up space but is useful for creating your own tools to load this dump files.
Turns out for the stats I had to recreate them from the trade history. It's possible the GetFitness method could be used but Id imagine thats only called for genetic optimization.
It's convienet to save the files to an archive. You need to add references
#r "System.IO.Compression" #r "System.IO.Compression.FileSystemThen the easiest thing is to create a temporary directory (Path.GetTempFileName and Path.GetTempPath are useful here) then write raw files as you normaly would and call `ZipFile.CreateFromDirectory(dir,outFileName)` then clean up.
Wow this is so good. Do you also know of a way of automating the running of backtest. Say I have a folder with 100 parmeter files and I want to backtest all of them for a particular time frame, i there any tool that can help me do that quickly instead of me sitting and manually backtesting each parameter one by one.
Thanks in advance.
@driftingprogrammer
driftingprogrammer
03 May 2020, 14:44
RE: RE: Just select
mihaidonos said:
Thanks a lot! I don't know how I've missed that :)
In order to back test renko I've made my own calculations. I have a cbot that keeps an array with renko bricks and can enter / exit if some consecutive bricks in one direction appear.
If anyone thinks this might be useful, I can publish it.
That sounds really interesting, I have implemented something similar myself. But I have been wanting to make a EMA crossover cBot on a renko chart, the problem is i have to run it on a renko chart otherwise i will not get the EMA i am looking for so i think i will not be able to backtest it.
I understand what you are doing is running your bot on a tick chart and making the historic renko blocks yourself, since you do not depened on an indicator that needs to be running on a renko chart that is the reason you are able to do this. It is a brilliant idea because now you can do backtesting and optimisation.
There is another github opensource project which is suppose to enable us to be able to backtest renko chart but i have not looked into it yet and I think it needs some work.
Cheers.
@driftingprogrammer
driftingprogrammer
03 May 2020, 08:39
( Updated at: 21 Dec 2023, 09:22 )
Just select
mihaidonos said:
Also, I saw this post: https://ctrader.com/forum/calgo-support/13950
PanagiotisCharalampous says: You can use cBots on Renko charts. There is no specific example as there is no difference to other chart types.
How do you do that?
Thanks in advance!
Just select Renko, it works fine, you are looking at the wrong place for renko graph.
@driftingprogrammer
driftingprogrammer
31 Mar 2020, 14:57
RE: Information already provided
PanagiotisCharalampous said:
Hi driftingprogrammer,
I still need the exact chart you are using. Which renko/range chart is it? Just send us a full screenshot of cTrader and we will figure this out.
Best Regards,
Panagiotis
Hi Panagiotis,
As I mentioned in the first sentenence of my post "There are few charts like the one below AUDJPY (AUDCAD)", So you can open any of these charts on Renko or Range Block size of whatever 20,30,40,50,100 and you should be able to see the pattern whose screenshot I have provided on that particular date. If you look at the graph for 50 pips you might not even need to scroll, it will show up immidieately on the screen.
I am not sure what exact information you want from me, please let me know if I have missed something. There are atleast a couple more with that pattern but i think having 2 examples should be sufficient.
Thanks in advance,
Warm Regards,
Ben.
@driftingprogrammer
driftingprogrammer
30 Mar 2020, 16:24
My broker is pepperstone and the graphs are the ones I mentioned earlier. There are few more that have that wierd pattern on that particular day.
@driftingprogrammer
driftingprogrammer
17 Mar 2020, 09:23
RE: Account based roboit
PanagiotisCharalampous said:
Hi driftingprogrammer,
There is no such option at the moment.
Best Regards,
Panagiotis
I am able to get my robot to log all positions opened on a particular account (the account on which the third party robots are running) and take corrective actions when the third party robot does something.
I am doing this by subscribing to the Postion Opened, Closed and Modified events which notifies me for all trades being opened on that account.
The only problem is if it was possible to get invoked before the trade opens and have the control to cancel it altogether.
Such a feature would be really helpful for algorithmic traders, i feel.
Thanks for your response.
Cheers.
@driftingprogrammer
driftingprogrammer
13 Mar 2020, 03:43
A monitoring Robot
Hi,
I wanted to cbot to be able to shutdown the cbot that i have purchased from third party. Has there been an API released allowing us to stop and start robots through function calls. Since the robot i want to invoke is a third party robot i cannot modify it to look for a folder and other workaround like that.
Thanks.
@driftingprogrammer
driftingprogrammer
13 Mar 2020, 03:30
Is this still the only solution
lucian said:
One cBot create a folder:
[Parameter(DefaultValue = C:)] public string drive { get; set; } protected override void OnTick() {if (something) { string path = drive + ":/StartXcBot"; System.IO.Directory.CreateDirectory(path); } }and XcBot read if folder exist:
[Parameter(DefaultValue = C:)] public string drive { get; set; } protected override void OnTick() { string path = drive + ":/StartXcBot"; if (System.IO.Directory.Exists(path)) { do something } }
Is this still the best way, somebody mentioned on the chat room that there is now an API to invoke a cbot from another cbot, and it seems there is also a way to pass the parameter file.
The problem is i cannot use the above solution since the cbot i am invoking is a third party cbot.
Thanks.
@driftingprogrammer
driftingprogrammer
11 Mar 2020, 14:20
RE: RE: Can we buy the whole suit now
sifneosfx said:
Hi Ben,
it makes no sense to run the same asset in two different timeframes, as on one the system may find a sell signal and on the other a buy signal. This will confuse your trading for sure. I strongly recommend to use just one instance of the asset and decide wherever to run it on 4h or 1h. We will not build in such a function to distinct between timeframes as we see it as non productive.
We will not introduce any new parameters as parameters we have delivered are samples. Because every broker delivers different historically data, the results always vary. It is your duty to find best parameters for any given asset, timeframe, broker.
Customer are informed by mail on new versions. All updates are for customers free, lifetime.
Hope that helps...
driftingprogrammer said:
Hi,
I have been testing your robot on all 30 parameters.
There are 2 markets which are running on both 1 hr and 4 hr timeframe. By looking at the log output is it possible to make a distinction between the outputs of these 2 robots.
I have found in the last one month the robot has performed extremely poorly on NZDUSD using the default parameters that come with the download. I am unable to assess weather both the instances of NZDUSD are performing poorly or only one of them is performing poorly.
If it is not possible to make that distinction it would be great if such a feature is added sometime in the future,
Is it ok to go ahead and buy the Robot now. After buying the robot when you intriduce new parameters for new markets or update existing parameters for better performance how do you inform the existing customers.
Please let me know.
Thanks in advance.
Cheers.
Here are the test results of running all the 30 parameters for the last 48 hours, one would think that during these times the robot might fail but he performed much better, while i was not expecting more then 20% monthly return it gave a 40% return in 2 days ->
@driftingprogrammer
driftingprogrammer
11 Mar 2020, 13:19
RE: RE:
driftingprogrammer said:
PanagiotisCharalampous said:
Hi noeyamn,
The problem seems to be that SQLite .Net dll is referencing other dll files which cannot be found when it is looking in the folder of cTrader application. The workaround is to add a folder in Documents e.g. "sqllite" and add SQLite.Interop.dll file there. The cBot can add this folder to Path environment variable so that this folder would be searched too. See below an example
using System; using System.Data.SQLite; using System.IO; 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.FullAccess)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { AddSqlightFolderToPath(); var dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "mydatabase.db"); var con = new SQLiteConnection("Data Source=" + dbPath); con.Open(); Print("DB connection: ", con.State); } private void AddSqlightFolderToPath() { var libPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "sqllite"); var path = Environment.GetEnvironmentVariable("PATH"); var pathItems = path.Split(';'); Print(libPath); if (!pathItems.Contains(libPath)) Environment.SetEnvironmentVariable("PATH", path + ";" + libPath); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
Panagiotis
Glad you were able to replicate the issue, thanks for the solution.
Can you please let us know what versuon of SQLite driver did you donwload from Nuget.
Thanks in advance.
@driftingprogrammer
driftingprogrammer
11 Mar 2020, 13:18
RE: I think Robot is still stuck with .NetFramework 4 Client Profile
driftingprogrammer said:
I am not sure i understand how to move my robot to higher versions of .Net Framework.
Here is a post which complains that i am unable to use SQLite from my cbot. -
When i tried using Postgres i did what is recommended, take a fresh robot, open in Visual Studio 2017, change the .net framework in the project properties to 4.6.1 from 4.0 Client Profile.
This enables me to get the latest Postgres package from nuget.
But while running this as a console application would be fine when i run it as a robot i get the following error
'FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral
In ioder to fix that i need to create a new project and not increase its .Net Framework version but rather select a older version of the postgres package on nuget to be able to install it on my project.
After compilation now when i run my robot it is able to connect to the postgres database from inside cTrader.
(Although this methodology did not fix the SQLite connectivity issue) This shows to me that although one can compile the code using latest packages from nuget, if it needs to actually be able to run in cTrader it needs to run against the version of those tools that were built for the older version 4 Client Profile to be specific in this case.
jaredthirsk said:
I think this discussion as a prerequisite needs to understand in-place upgrades for .NET 4. Here are some articles from 2012 that perhaps give an adequate overview:
https://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx
https://weblog.west-wind.com/posts/2012/Mar/13/NET-45-is-an-inplace-replacement-for-NET-40
Suggestion for Spotware: for your new Robot/Indicator csproj project templates, change the default to something from this era, like 4.6.1 or 4.7.2 or 4.5 or something. 4.0 Client Profile may technically work (if I understand it right?) but it sounds like people have problems with nuget (?) so it might be better to at least go to 4.5.
SQLite connectivity issue was resolved using the workaround mentioned here -
@driftingprogrammer
driftingprogrammer
11 Mar 2020, 13:18
Solution
We finally have a solution after 5 years -
@driftingprogrammer
driftingprogrammer
11 Mar 2020, 13:16
RE:
PanagiotisCharalampous said:
Hi noeyamn,
The problem seems to be that SQLite .Net dll is referencing other dll files which cannot be found when it is looking in the folder of cTrader application. The workaround is to add a folder in Documents e.g. "sqllite" and add SQLite.Interop.dll file there. The cBot can add this folder to Path environment variable so that this folder would be searched too. See below an example
using System; using System.Data.SQLite; using System.IO; 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.FullAccess)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { AddSqlightFolderToPath(); var dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "mydatabase.db"); var con = new SQLiteConnection("Data Source=" + dbPath); con.Open(); Print("DB connection: ", con.State); } private void AddSqlightFolderToPath() { var libPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "sqllite"); var path = Environment.GetEnvironmentVariable("PATH"); var pathItems = path.Split(';'); Print(libPath); if (!pathItems.Contains(libPath)) Environment.SetEnvironmentVariable("PATH", path + ";" + libPath); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
Panagiotis
Glad you were able to replicate the issue, thanks for the solution.
@driftingprogrammer
driftingprogrammer
10 Mar 2020, 13:24
Can we buy the whole suit now
Hi,
I have been testing your robot on all 30 parameters.
There are 2 markets which are running on both 1 hr and 4 hr timeframe. By looking at the log output is it possible to make a distinction between the outputs of these 2 robots.
I have found in the last one month the robot has performed extremely poorly on NZDUSD using the default parameters that come with the download. I am unable to assess weather both the instances of NZDUSD are performing poorly or only one of them is performing poorly.
If it is not possible to make that distinction it would be great if such a feature is added sometime in the future,
Is it ok to go ahead and buy the Robot now. After buying the robot when you intriduce new parameters for new markets or update existing parameters for better performance how do you inform the existing customers.
Please let me know.
Thanks in advance.
Cheers.
@driftingprogrammer
driftingprogrammer
10 Mar 2020, 11:31
The problem isolated
Below is the code that runs fine as expected. It can also be backtested and nothing will fail.
But when I run it against the optimiser it fails.
I have this issue on all the 3 computers of mine.
This problem is new started around 48 hours back.
It is related to corrupt data that is being sent to the optimiser.
Even in backtesting this problem ocurs intermittently, at times i was facing this issue while testing for dates earlier then August 2019.
I hope this gets fixed soon as you can imagine not having the optimiser working is a big problem.
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
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
// Put your initialization logic here
Bars tempBars = MarketData.GetBars(TimeFrame.Minute15);
Print("Printing tik volume " + tempBars.Last(1).TickVolume);
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Thanks in advance.
@driftingprogrammer
driftingprogrammer
09 Mar 2020, 18:56
( Updated at: 21 Dec 2023, 09:21 )
RE:
PanagiotisCharalampous said:
Hi noeyamn,
You did not answer my question. Why do you add references manually? I installed SQLite using Package Manager and I have no problems. See below
Everything seems fine and the cBot builds without a problem.
Best Regards,Panagiotis
Have you been able to run the program, can you please share screenshot of a running robot printing out the successful connection object to the database.
Thanks in advance.
@driftingprogrammer
driftingprogrammer
18 Aug 2020, 12:52 ( Updated at: 18 Aug 2020, 14:01 )
There is no way to delete the post, please vote for earlier suggestions.
Please vote for -
@driftingprogrammer