Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, wandaluciaia, 1 invisible), 798 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Compiling Trading Strategies with C++ #467657
08/19/17 11:01
08/19/17 11:01
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

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:
Quote:
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#p53792

I 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.htm

Any 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
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
Perhaps you can find some help here?
http://www.zorro-trader.com/manual/en/litec_api.htm

Re: Compiling Trading Strategies with C++ [Re: Dalla] #467666
08/20/17 10:18
08/20/17 10:18
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Yes, but contrary to importing functionality to lite-c I would like to use the zorro trading framework in c++ natively. From what I read zorro was developed in C++, so technically it should be possible. I just did not find yet how this is exposed. The post from jcl suggests it is possible.

Re: Compiling Trading Strategies with C++ [Re: pascalx] #467693
08/22/17 18:22
08/22/17 18:22
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

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.htm
But 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: pascalx] #467700
08/23/17 13:01
08/23/17 13:01
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
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.

Re: Compiling Trading Strategies with C++ [Re: jcl] #467703
08/23/17 16:21
08/23/17 16:21
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Originally Posted By: jcl
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: pascalx] #467718
08/24/17 16:24
08/24/17 16:24
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
All system variables are in the "g" struct, so you only need to pass a pointer to that struct. The file "variables.h" contains the defines of all variables. The calling convention is __cdecl.

Re: Compiling Trading Strategies with C++ [Re: jcl] #467771
08/29/17 16:26
08/29/17 16:26
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
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.

Re: Compiling Trading Strategies with C++ [Re: jcl] #467776
08/30/17 07:42
08/30/17 07:42
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Originally Posted By: jcl
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)
Code:
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
Code:
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.htm

Assuming 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.
Re: Compiling Trading Strategies with C++ [Re: pascalx] #467900
09/06/17 17:29
09/06/17 17:29
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Oh hey, what's this? laugh


Attached Files Capture.JPG
Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1