Topics
Replies
jaredthirsk
01 Jun 2019, 11:43
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.
@jaredthirsk
jaredthirsk
01 Jun 2019, 11:37
RE: RE: RE: .NET 4
jaredthirsk said:
+1
.NET 4 Client Profile is basically abandoned by Microsoft -- everybody has moved on (.NET 4.6.2). Is cTrader/cAlgo abandoned?
As a followup to my comment from 21 months ago: the recent changes to cTrader are impressive, and it doesn't feel abandoned (anymore) -- it feels like it is getting some love. Keep up the good work and I hope you prioritize features that make the biggest difference to successful trading.
@jaredthirsk
jaredthirsk
01 Jun 2019, 11:16
RE: RE: Fixed!
mpistorius said:
andrewfblake said:
I had this problem too and did not want to change anything in cAlgo.... but managed to fix it simply by editing the Bot in Visual Studio and updating that to the new framework 4.6.2.... It then calls my Class Library in 4.6.2 and works like a dream... no need for Spotware to do any updates :-)
Would you care to elaborate on this, please? Is there some workaround to use new language features from, say C#7? When I try to build my project in Visual Studio, I still get errors from the cAlgo extension trying to build a .algo file. And I cannot disable the extension, then the project won't load.
What errors are you seeing? People may be able to help if they know.
FWIW, my workflow: (admittedly complex, most people should maybe ignore most of this unless they are going deep into coding possibilities like me, though maybe it shows how you might be able to use newer .NET)
- For most of my code, I prefer .NET Standard 2.0 (I create DLLs from Visual Studio) and I believe I use the latest language features, C# 7.3 whatever, though I don't know if I'm using the new data types like tuples and Span<>s and such or if those would conflict.
- The DLL I reference from cTrader in my algos is currently .NET 4.7.2. I will probably try 4.8 here soon. There isn't much code in this DLL -- it mostly pulls in my other netstandard DLLs. I created this DLL from Visual Studio.
- I am a programming junkie and have a bunch of DLLs, but it is a pain to get a kajillion references correct in all my cAlgo projects, so I merge everything to one DLL using ILRepack as a post-build event.
- When I create a new bot in cTrader, I go to add references and add my one big DLL (.NET 4.7.2). I just leave the cTrader project at whatever Spotware created it as -- I guess Spotware still defaults to 4.0 Client? That is crazy, but I guess it doesn't matter to me. I noticed on one bot I made, I changed the cAlgo\Sources\Robots\xyz\xyz.csproj to v4.7.2, though I don't think I even need to do this, generally speaking:
- Default:
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- New:
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
- Default:
- My new bots in cTrader references a base class instead of Robot, so that I get some logic from my base class, such as my custom GetFitness scoring system. (I base it on annualized ROI divided by max equity drawdown.)
- For some bots, I started moving most trading logic to my own DLLs. I am hoping to at some point host them in my own .NET console app and use FIX protocol, instead of hosting them inside of cTrader, which is a resource hog if I want to run say 200+ bots, which I think is actually a reasonable goal for people working towards being serious algotraders. Also, I have a memory leak problem when optimizing using cTrader (not sure if it's my fault or spotware's), and if I only have one VPS that did both (probably demo account) bots and optimization, I obviously wouldn't want to shut down and restart cTrader and start all the bots up again every time I ran out of memory. I don't want to have to rent a bunch of expensive VPS's. I plan to run them on relatively cheap linux VPS's using .NET Core.
- Long-term FEATURE REQUEST: Ideally, Spotware would release some sort of UI-less bot service for running bots, and a command line interface to start/stop/query bots, which runs on .NET Core and supports Windows/Linux(/and it may work on Macs for free.)
- I forgot what the Visual Studio extension even does. But I should try to do the right click and edit in Visual Studio thing more often, since editing within cTrader is relatively painful (yet convenient) IDE compared to VS2019.
- I use new Newtonsoft.JSON (version 12)
- Every time Spotware releases a new version of cTrader, I have to hunt down the cTrader.exe.config file in c:\users\myname\appdata\local\apps\2.0\{random}\{random}\brokername...ctrader...\ and do a .NET Assembly binding redirect for Newtonsoft.Json to whatever version Spotware is using. Spotware has been shipping v9 but I see they just switched to v10. Hurrah. I might switch to another JSON serializer just to avoid having to do this. Since I am logging optimization runs, I might get a perf boost if I switch to a more performant library anyway. Microsoft started shipping their own very fast serializer -- I might try that if it is compatible.
- Caveat: I'm not 100% sure how safe this is, or if anything could possibly break from one version of cTrader to the next, though I tend to think that if all netstandard2.0 and .NET 4.7.2 code paths of my bot work, then I am probably good for the time being.
@jaredthirsk
jaredthirsk
21 Jun 2018, 15:40
RE:
Panagiotis Charalampous said:
Hi Jared,
Please send it at community@spotware.com.
Best Regards,
Panagiotis
I sent it in. Thanks for looking into it.
@jaredthirsk
jaredthirsk
21 Jun 2018, 11:58
RE:
Panagiotis Charalampous said:
Hi Jared,
Thanks for pointing this out. We are having a look at it. Any change you could share the cBot with us?
Best Regards,
Panagiotis
Sure, is there a way I can send it to you?
@jaredthirsk
jaredthirsk
09 Oct 2017, 05:54
RE:
jaredthirsk said:
Update: I updated my app in the App Store, but now instead of saying "Open this page in ...__" it doesn't do that, and I am stuck at a website. My options are to change my language or log out or view my profile.
... same thing on iPad. All I see is the webpage "Why cTrader ID improves my trading experience".
@jaredthirsk
jaredthirsk
09 Oct 2017, 05:48
Update: I updated my app in the App Store, but now instead of saying "Open this page in ...__" it doesn't do that, and I am stuck at a website. My options are to change my language or log out or view my profile.
@jaredthirsk
jaredthirsk
21 Sep 2017, 02:25
Thanks, Rhett, I will keep that in mind.
It might be good for Spotware (or brokers) to have some sort of automatic rogue bar detection feature, ideally for live data (filter out bad data in the first place, or maybe it is tiny LP's with a nearly empty order book getting switched on before the rest of the LP's?) but at least so it fixes up the backtest data within a few days of it happening.
@jaredthirsk
jaredthirsk
13 Sep 2017, 09:01
Another rogue bar, on XAUUSD:
Gold spikes down to 1245 to 692 at 5:32am June 4, 2014, (UTC-6, so maybe 11:32 UTC.)
@jaredthirsk
jaredthirsk
11 Sep 2017, 09:24
Another problem people are going to run into: max SL in cTrader is 50000 pips ($5 USD), which is going to be too small.
@jaredthirsk
jaredthirsk
11 Sep 2017, 09:22
Another more severe problem:
VolumeStep and VolumeMin are 0, which I'm guessing causes ExecuteMarketOrder to crash with a DivideByZeroException (after fixing my own code that crashed due to these nonsensical values.)
@jaredthirsk
jaredthirsk
20 Mar 2017, 04:03
[Fixed] (but it's ugly)
Ok, I've got my .NET Core dlls working without errors! (I can start a bot, backtest, and optimize.)
What I did:
- Turn on fusion log to detect .NET assembly loading problems. Ran fuslogvw.exe to help me see the logs, or look at them on disk.
- In my bot, I added some Microsoft references: System.Collections, System.Threading, etc. Not sure this helped
- Added some assembly redirects as needed in the cAlgo.exe.config (in some obscure folder in AppData\Local\Apps\2.0\....garbagenames...\cAlgo.exe.config
- Copied missing DLLs into this folder as well.
I'll probably have to repeat this the next time a new version of cAlgo comes out. I will write a script to automate it if I have to.
Anyway, Spotware, if you can make sure .NET Core development is a first class experience, that would seem like a good thing. And anyone, if I am missing something that could make this easier, please let me know.
------------
Appendix - Assembly redirects I added to cAlgo.exe.config:
<dependentAssembly> <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Collections" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Diagnostics.Debug" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Threading" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.0.12.0" newVersion="4.0.12.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Collections.Concurrent" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="4.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly>
@jaredthirsk
jaredthirsk
16 Mar 2017, 10:10
The debugger also says clrType is null. So maybe it is having trouble loading my type -- I seem to recall I had trouble before if I didn't reference all of my DLL's (I have a lot of them.) I will try to ensure I have all DLLs added....
@jaredthirsk
jaredthirsk
16 Mar 2017, 10:06
Oh I turned off "Just my code" when debugging and get a NullReferenceException in Frontend.CrossDomain:
System.NullReferenceException occurred
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Frontend.CrossDomain
StackTrace:
at Frontend.CrossDomain.Wrapper.DesktopAlgoActivator.CreateInstance[TAlgo](Type clrType, Dictionary`2 parameterValues)
@jaredthirsk
jaredthirsk
27 Feb 2017, 09:35
RE:
tmc. said:
Hi, Time Series Moving Average is equal to Linear Regression Forecast. The cAlgo platform calculates it by multiplying Linear Regression Slope with Period plus Linear Regression Intercept. Here's is better solution that gives you same result.
Awesome, thanks!
Vidya is the other moving average I was wondering about. Do you know the best way to calculate that?
@jaredthirsk
jaredthirsk
21 Dec 2016, 10:21
Same problem. Haven't paid too close attention but it looks like several minutes, maybe 30 minutes late.
Broker: IC Markets but if more than one broker is having a problem maybe it's not their issue.
@jaredthirsk
jaredthirsk
11 Dec 2016, 01:43
One tip: make sure the file is not opened in another app (or in both backtesting/optimization tabs?) Try making a copy of the file.
@jaredthirsk
jaredthirsk
03 Aug 2020, 22:49
[edited: resolved one of my own performance issues that I realized I created due to experimentation with performance. Still keeping an eye on things.]
@jaredthirsk