I am wondering whether it is possible to use python to create basic logics, and compile into C++ DLL (maybe using cython or something?) that is usable by Multicharts?
Because C++ is really hard to write code lol Python is a lot easier.
I am wondering whether anyone have used this approach and success?
Any share of experience or approach of using python to create DLL will be super appreciated
Use python to compile C++ DLL that is usable by Multicharts
-
- Posts: 87
- Joined: 10 Feb 2022
- Has thanked: 53 times
- Been thanked: 11 times
Re: Use python to compile C++ DLL that is usable by Multicharts
This will probably be possible in principle, but probably only in the multicharts.net application. But I'm wondering if you know Python why you don't use C# directly. C# is more complex but it has its limits. There should also be ironpython for the .net environment, which should offer integration with python. In principle, for performance reasons, it is better to stick with C#.
I only know one reason why I would use Python at all and that is the extensive libraries in the area of machine learning, but Microsoft now offers ml.net there too.
All in all, I would advise against the project because of its complexity, but as you write, it is basically possible.
I only know one reason why I would use Python at all and that is the extensive libraries in the area of machine learning, but Microsoft now offers ml.net there too.
All in all, I would advise against the project because of its complexity, but as you write, it is basically possible.
Re: Use python to compile C++ DLL that is usable by Multicharts
Hmmm, so you mean it is possible to use python to compile C++ DLL that is usable by Multicharts?
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Use python to compile C++ DLL that is usable by Multicharts
[Advanced Topic] MultiCharts 64 bit Resources (3rd Party)
viewtopic.php?t=10094
viewtopic.php?t=10094
Re: Use python to compile C++ DLL that is usable by Multicharts
Hi
If your using Multicharts.Net you can use the Python.NET package and call oythong code directly
from your scripts. However you will run into All sorts of Memory's type errors because multicharts
is mulithreaded app and python is single threaded. To over come those errors I wrote someC# classes
which handle those issues. Just Google calling Python .net from multithreaded C# app and you will find the results.
If your using Multicharts Powerlanguage version, I have written a Python DLL which basically allows you to
call almost any python function directly from Multicharts Powerlanguage. Im able to call Numpy, scikit learn tensorflow
SFTP uploads and many more python functions. It supports a variety of functions.
If you want to add a custom function to the DLl then it does require some programming knowledge.
PM me for more details.
If your using Multicharts.Net you can use the Python.NET package and call oythong code directly
from your scripts. However you will run into All sorts of Memory's type errors because multicharts
is mulithreaded app and python is single threaded. To over come those errors I wrote someC# classes
which handle those issues. Just Google calling Python .net from multithreaded C# app and you will find the results.
If your using Multicharts Powerlanguage version, I have written a Python DLL which basically allows you to
call almost any python function directly from Multicharts Powerlanguage. Im able to call Numpy, scikit learn tensorflow
SFTP uploads and many more python functions. It supports a variety of functions.
If you want to add a custom function to the DLl then it does require some programming knowledge.
PM me for more details.
-
- Posts: 87
- Joined: 10 Feb 2022
- Has thanked: 53 times
- Been thanked: 11 times
Re: Use python to compile C++ DLL that is usable by Multicharts
Do you use tensorflows for multicharts.net and if so, for what? And in general, why did you do this, C# is already pretty powerful. Did you need any special Python libraries?
Re: Use python to compile C++ DLL that is usable by Multicharts
Before I was using Powrlanguage a lot for all my strategies so the fastest way to call Python functions was to create a C++ DLL which opens a Python Interpretor and keeps the interpreter Open. MC sends Python functions to the Interpretor and returns the output back to MC. I am using most Python libraries in my functions such as pandas numpy keras tensorflow scikit learn etc.
All my research was done in python and execution on MC so in order to get the same results in live trading as my research I to integrate the two.
Regarding C#, C# is very powerful but MC is not. Most of the .net libraries which allow Python functions such as tensorflow.net, Python.net, Numpy.net, SciSharp.net have very limited features compared to the real Python versions amd their latest bug free versions of these libraries are not compaitble with MCs .net framework 3.5 and 4.0.
You can call the Python Functions directly in #C using Python.net but you need to create many custom C classes to start Python, change Environment Paths , Special code to exit Pythin and running Python.net with Multicharts.NET is a nightmare due to MC.net being Multithreaded so you need more code to make the app threasade. And due to the Interop between C# and Python the code becomes slow. However once you have done all the above its quite seamless to call pretty much any Python function even in .net but it is a slower than calling a function from the DLL designed for MC powerlanguage
All my research was done in python and execution on MC so in order to get the same results in live trading as my research I to integrate the two.
Regarding C#, C# is very powerful but MC is not. Most of the .net libraries which allow Python functions such as tensorflow.net, Python.net, Numpy.net, SciSharp.net have very limited features compared to the real Python versions amd their latest bug free versions of these libraries are not compaitble with MCs .net framework 3.5 and 4.0.
You can call the Python Functions directly in #C using Python.net but you need to create many custom C classes to start Python, change Environment Paths , Special code to exit Pythin and running Python.net with Multicharts.NET is a nightmare due to MC.net being Multithreaded so you need more code to make the app threasade. And due to the Interop between C# and Python the code becomes slow. However once you have done all the above its quite seamless to call pretty much any Python function even in .net but it is a slower than calling a function from the DLL designed for MC powerlanguage
Re: Use python to compile C++ DLL that is usable by Multicharts
Basically there's a solution for both MC Powrlanguage and MC.net
With MC PL you need to be a bit familiar with C++ to call Python
With MC.net you need to be familiar with C# and be ok with slightly slower runtimes
With MC PL you need to be a bit familiar with C++ to call Python
With MC.net you need to be familiar with C# and be ok with slightly slower runtimes
-
- Posts: 87
- Joined: 10 Feb 2022
- Has thanked: 53 times
- Been thanked: 11 times
Re: Use python to compile C++ DLL that is usable by Multicharts
thank you for the very comprehensive answer!!! But you haven't answered one question yet: what do you use tensorflows for? Because according to multicharts, optimizations due to the "data series" cannot be meaningfully implemented on the graphics card. (there is an extensive contribution to this)
If you have already dealt so extensively with the integration of Python and multicharts, why not make your code available to the developers of multicharts.net (possibly with a financial contribution?). maybe that would be a possible addon for multicharts. Python is a very popular programming language and this option would probably attract many more customers...
If you have already dealt so extensively with the integration of Python and multicharts, why not make your code available to the developers of multicharts.net (possibly with a financial contribution?). maybe that would be a possible addon for multicharts. Python is a very popular programming language and this option would probably attract many more customers...
Re: Use python to compile C++ DLL that is usable by Multicharts
Also worth looking at Pytorch as well as TensorFlow. They each have their pros and cons, depending on what you want to do. People have used Pytorch with a variety of trading platforms, including MC.
Re: Use python to compile C++ DLL that is usable by Multicharts
thank you for the very comprehensive answer!!! But you haven't answered one question yet: what do you use tensorflows for? Because according to multicharts, optimizations due to the "data series" cannot be meaningfully implemented on the graphics card. (there is an extensive contribution to this)
If you have already dealt so extensively with the integration of Python and multicharts, why not make your code available to the developers of multicharts.net (possibly with a financial contribution?). maybe that would be a possible addon for multicharts. Python is a very popular programming language and this option would probably attract many more customers...
I have offered to share my code to Multicharts for their Powerlanguage version and for .net version but I dont' think Python is on hteir priority list so far.thank you for the very comprehensive answer!!! But you haven't answered one question yet: what do you use tensorflows for? Because according to multicharts, optimizations due to the "data series" cannot be meaningfully implemented on the graphics card. (there is an extensive contribution to this)
If you have already dealt so extensively with the integration of Python and multicharts, why not make your code available to the developers of multicharts.net (possibly with a financial contribution?). maybe that would be a possible addon for multicharts. Python is a very popular programming language and this option would probably attract many more customers...
You would use Tensorflow to train a DeepLearning Model using a variety of data ( can be Ooen, high , low,close, RSI, Moving AVerages,etc a bunch of features) to make a trading prediction. ie. ( Buy, Sell,Hold , or 1,-1, 0 )
Based on your prediction from Deeplearning model you decide in multicharts to buy, sell or dont trade.
Regarding Optimizations :
Optimizations can be a bit complicated using python and multicharts due to threading issues.
Also just to clarify, A Multicharts Optimization whereby Multicharts calculates the performance of your strategy based on the buy , sell, etc trading decisions in your multicharts srcipt cannot be run on a GPU. However any C++ Python DLL or Python C Classes can run Optimziations and Fitting of your desired Machine Learning or Deep learning models on a GPU directly from within a powerlanguage signal file. However, you need to have some progrmaming knowledge to get around the threading issues.
For Newby Programmers I would suggest for Opimizations, you should save your MC data series to csv files via your powerlanguage script.
Inside your powerlanguage signal file, you can write
Code: Select all
if barstatus=2 then
{ Some FileAppend functionality to write the ohlc and your features to a csv file. Take a note of the lcoation where you saved your csv file.}
So you will run the tensorflow/Scikit learn optimization externally through another python script triggered within your powerlanguage signal file.
For example you can add this to your powerlanguage signal file
Code: Select all
if lastbaronchart then
{
trigger your extenal python script here for optimizations
One of the inputs to the external file will be the location where you saved your csv file with the data from MC
}
If anyone needs help integrating Keras, Tensorflow, etc to MC please PM me.
Re: Use python to compile C++ DLL that is usable by Multicharts
amw_775, thanks for the info.
Could your Python DLL be used to just load a specific pre-trained keras model, pass it inputs, and get a predicted value back? If so, I would be very interested.
That's all I'm trying to do, but piecing together the details on how to build a DLL (which C++ compiler to use, which architecture flags to use with the compiler, link in the python tensorflow C++ libraries, link in plkit.dll?, etc.) with the current level of MC documentation is challenging.
Could your Python DLL be used to just load a specific pre-trained keras model, pass it inputs, and get a predicted value back? If so, I would be very interested.
That's all I'm trying to do, but piecing together the details on how to build a DLL (which C++ compiler to use, which architecture flags to use with the compiler, link in the python tensorflow C++ libraries, link in plkit.dll?, etc.) with the current level of MC documentation is challenging.
Re: Use python to compile C++ DLL that is usable by Multicharts
Is it possible to use SharedVar Server as intermediate?
https://fx1.net/sharedvar.php
python -> SharedServer DLL -> SharedServer -> MC signal
however SharedServer don't support historical though...
https://fx1.net/sharedvar.php
python -> SharedServer DLL -> SharedServer -> MC signal
however SharedServer don't support historical though...
Re: Use python to compile C++ DLL that is usable by Multicharts
MC should consider adding few functions to communicate through 3rd party applications for user friendly coding.
I request all to vote for this feature "Read from file" function addition in MC
https://www.multicharts.com/pm/public/m ... es/MC-2341
Thanks
I request all to vote for this feature "Read from file" function addition in MC
https://www.multicharts.com/pm/public/m ... es/MC-2341
Thanks
-
- Posts: 87
- Joined: 10 Feb 2022
- Has thanked: 53 times
- Been thanked: 11 times
Re: Use python to compile C++ DLL that is usable by Multicharts
So in the last few weeks I have dealt more intensively with machine (deep) learning and can also create simple neural networks, but I have problems when I want to use tensorflow because I cannot get the corresponding NuGet packages integrated into multicharts.net . I suspect that this is also due to the outdated framework of 4.0. Unfortunately, my question in the Multicharts.net forum is still unanswered. In general, from what I've read, tensorflow should be the best choice for doing deep learning. Of course, python requires extensive libraries but is generally slower with tensorflow.net you retain the performance and an extensive library. An alternative would also be ml.net, but this does not leave as much scope for your own extensive developments, but is very beginner-friendly. But I have no idea whether the Ml.net integration will work seamlessly. Currently, the highest priority for multicharts net should still be to upgrade their framework to 4.8 in order to be able to use current libraries and to take advantage of newer coding libraries. In general, I still miss effective interfaces to other functions (such as the quote manager or the built-in optimization function). Unfortunately, you are really almost limited to developing indicators, or you have to take numerous detours. I would like to see a more open codebase/interfaces here.