0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Compiling Trading Strategies with C++
#467657
08/19/17 11:01
08/19/17 11:01
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
Hello. I am new to this site. I was wondering how the Zorro trading functionality is meant to be compiled against c++. I did not find information about that in the Zorro Manual. Only found this post that suggests it is possible: lite-C has a 'real' debugger, but it's not implemented in Zorro yet. However, you can alternatively write your strategies in a C++ DLL and use your C++ development system for debugging. http://www.stevehopwoodforex.com/phpBB3/...start=60#p53792I see the C headers in Zorro/include but I found no static or dynamic library to link against. I looked into the resources of Zorro.exe and SED.exe but could not find anything suspicious there either. Also how do I register to the events in c++? Or do I need a proxy script that forwards the calls to dll exports? http://manual.zorro-trader.com/functions.htmAny help is much appreciated. Thanks.
|
|
|
Re: Compiling Trading Strategies with C++
[Re: pascalx]
#467659
08/19/17 18:15
08/19/17 18:15
|
Joined: Feb 2017
Posts: 369
Dalla
Senior Member
|
Senior Member
Joined: Feb 2017
Posts: 369
|
|
|
|
Re: Compiling Trading Strategies with C++
[Re: pascalx]
#467693
08/22/17 18:22
08/22/17 18:22
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
I have found no way yet to natively use Zorro in C++. Would be awesome to use it in Visual Studio. I have the impression the Zorro framework is really feature rich and purposefully organized. However I am surprised that the Zorro lite-C Editor is intended to be used without Debugging functionality. How do you guys track down coding errors? By logging? I was disappointed by the MQL4 debugger and MQL4 restrictions, but lite-C appears to be worse in that regard. The Gamestudio editor appears to have a debugger: http://www.conitec.net/litec/work17.htmBut I assume it is not compatible with Zorro? In the event C++ Zorro is not natively available, does anyone know of an existing C++ to lite-C bridge? If not, what do you think is the best approach to implement it? We could use a polling approach like the Zorro MT4/5 Bridge does, which will come with a hit on performance if we want to support the Zorro commands 1:1. Or we use a platform/language independent messaging like ZeroMQ. Maybe that would be the most elegant approach. Thus you could also write code in python or java or whatever.
|
|
|
Re: Compiling Trading Strategies with C++
[Re: jcl]
#467703
08/23/17 16:21
08/23/17 16:21
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
Although it is possible to code a strategy in a C++ Dll, it takes a bit more effort than writing it natively in C. You must write a C wrapper that acts as a Zorro strategy and calls your Dll via LoadLibrary() and GetProcAddress(). You also need to pass pointers to the indicators and trade functions that you want to use. The advantage of using the Visual Studio debugger is probably not worth the hassle.
Directly running strategies in Dlls is planned for a future Zorro version, but not yet available. Hi bro. Good thinking there. Passing pointers of the functions and static variables to the DLL would save some headache. For the zorro events we can use exported functions. Shouldn't be a problem to implement (I think). Well I guess it's just a matter of preference. I prefer C++ over C and feel more comfortable with it. Are all System Variables (LookBack, Stop, PIP, etc) static at all times? And are they all already instanced when we enter main() ? Or are there some that reallocate or instantiate later? And what is the calling convention of lite-c functions? Btw may I suggest to rename "User Supplied" in the zorro manual to something like "Script event functions"?
Last edited by pascalx; 08/24/17 07:01.
|
|
|
Re: Compiling Trading Strategies with C++
[Re: jcl]
#467776
08/30/17 07:42
08/30/17 07:42
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
We're looking for beta testers for the mentioned future interface for running strategies in DLLs. If you're interested, please contact support (at) opgroup.de. Obsolutely Sir. Mail sent. I had a go at implementing a pointer handover and it appears to be mostly no problem. I intent to use the headers from Zorro as-is without touching them. Thus I have to accompany the original function declarations with implementations, that in return call the function pointer given by lite-c. I created some simple macros that generate the required code from function definition list(s). Unfortunately the function declarations show no information about optional parameter values. Thus I have to a) check the zorro manual manually if some arguments are optional and b) then guess what the default value could be. I assume the primitive data types and pointers have a default value of 0 (always?). Not sure about string (char*). Also 0 (NULL) or "" (empty string) ? Maybe there are special cases where it is different but not documented? Finally I have to accompany those function declarations with an overload that specifies the optional argument values. So original function (as in functions.h)
TRADE* enterLong(function f,var v0,var v1,var v2,var v3,var v4,var v5,var v6,var v7,...)
{
return bridge::enterLong_ptr(f,v0,v1,v2,v3,v4,v5,v6,v7);
}
is accompanied by
TRADE* enterLong(int Lots=0, var Entry=0, var Stop=0, var TakeProfit=0, var Trail=0, var TrailSlope=0, var TrailLock=0, var TrailStep=0)
{
return bridge::enterLong_ptr(Lots, Entry, Stop, TakeProfit, Trail, TrailSlope, TrailLock, TrailStep, 0);
}
What I am wondering about in the case of enterLong, enterShort is the behaviour you impose according to the manual. http://www.zorro-trader.com/manual/en/buylong.htmAssuming there is just one enterLong function (as indicated by functions.h), and int/long are both 4 bytes, how does this function know if the first parameter means lot size or function ptr?
Last edited by pascalx; 08/30/17 09:30.
|
|
|
|