Use python to compile C++ DLL that is usable by Multicharts

Questions about MultiCharts and user contributed studies.
rc76
Posts: 51
Joined: Oct 14 2020
Has thanked: 17 times

Jan 17 2024

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

HellGhostEvocatorX
Posts: 143
Joined: Feb 10 2022
Has thanked: 68 times
Been thanked: 23 times

Jan 17 2024

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.

rc76
Posts: 51
Joined: Oct 14 2020
Has thanked: 17 times

Jan 17 2024

Hmmm, so you mean it is possible to use python to compile C++ DLL that is usable by Multicharts?

User avatar
TJ
Posts: 7774
Joined: Aug 29 2006
Location: Global Citizen
Has thanked: 1036 times
Been thanked: 2233 times

Jan 18 2024

[Advanced Topic] MultiCharts 64 bit Resources (3rd Party)
viewtopic.php?t=10094

amw_775
Posts: 27
Joined: Apr 19 2020
Has thanked: 1 time
Been thanked: 18 times

Feb 04 2024

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.

HellGhostEvocatorX
Posts: 143
Joined: Feb 10 2022
Has thanked: 68 times
Been thanked: 23 times

Feb 07 2024

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?

amw_775
Posts: 27
Joined: Apr 19 2020
Has thanked: 1 time
Been thanked: 18 times

Feb 19 2024

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

amw_775
Posts: 27
Joined: Apr 19 2020
Has thanked: 1 time
Been thanked: 18 times

Feb 19 2024

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

HellGhostEvocatorX
Posts: 143
Joined: Feb 10 2022
Has thanked: 68 times
Been thanked: 23 times

Feb 21 2024

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

janus
Posts: 844
Joined: May 25 2009
Has thanked: 64 times
Been thanked: 106 times

Feb 21 2024

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.

amw_775
Posts: 27
Joined: Apr 19 2020
Has thanked: 1 time
Been thanked: 18 times

Apr 13 2024

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

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.}
Run the optimziations by triggering an external python script via powerlanguage or .net.
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 }
For Powerlanguage use Lua or my Python DLLto run the external script or for .Net use the functionality of "Process" and "ProcessStartInfo" to trigger an external python script optimizations.

If anyone needs help integrating Keras, Tensorflow, etc to MC please PM me.

tmespy
Posts: 1
Joined: Apr 25 2024

Apr 29 2024

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.

rc76
Posts: 51
Joined: Oct 14 2020
Has thanked: 17 times

Apr 30 2024

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

User avatar
faraz
Posts: 204
Joined: Feb 25 2011
Location: 1stchoicestrategy.com
Has thanked: 26 times
Been thanked: 67 times

May 01 2024

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

HellGhostEvocatorX
Posts: 143
Joined: Feb 10 2022
Has thanked: 68 times
Been thanked: 23 times

May 01 2024

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.

amw_775
Posts: 27
Joined: Apr 19 2020
Has thanked: 1 time
Been thanked: 18 times

Jul 22 2024

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.
Hey HellGhostEvocatorX

I have been through the same tiring excercise. ML.net wont work with MC.net because MCnet is built on .net framework 4.0 whereas ML.net requires .net Standard 2 + or .net Framework 5 and above if im not mistaken.

I was first calling Tensorflow from using tensorflow.net, numpy.net and all the .net supported packages via Multicharts.net but I would constantly run into Errors. FYI all the above .net packages are actually using C# and then calling Python.net and then calling the respective package such as tensorflow,numpy etc via Python.net

Finally I resorted to using the Python.net Package. You can call Python.net from Multicharts.net but you will again run into issues when you import packages like tensorflow, and numpy due to multi threading.

So now finally, I have a Multicharts.NET Python Class which allows you to call Python.NET succesfully. You can import any package you like from python and directly write the code inside Multicharts.Net Editor as if you are writing Python.
Ofocurse since I am a proffesional programmer and trader I am willing to sell the class and provide programming support and I can share the class with sample scripts. DM me if this of interest to

amw_775
Posts: 27
Joined: Apr 19 2020
Has thanked: 1 time
Been thanked: 18 times

Jul 22 2024

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.
Yes this can be done. I dont suggest building it yourself unless you are a proffesional C++ programmer.
It took me over 6 months to build because of threading issues in numpy, and all the marshalling required between easylanguage, c++ and python and the marshalling back from python to c++ to easy language.

The Python C++ DLL which I built for MC powerlanguage can do this.
It currently has this feature for loading trained sklearn models.
The Values that need to be passed on from MC are passed on as an array to the sklearn model.
The prediction value is returned back from the sklearn model and sent to multicharts,

Multicharts reads that Predicted value and you can write powerlanguage code to take action based on that prediciton.

All of this is done within the python C++ DLL .

So yes I can easily add the Keras model fucntions. Im well versed with keras library.

See attached Python File. The following functions are supported at present :

Code: Select all

import os import random import datetime import pandas as pd from importlib import reload os.chdir("c:\Projects.Py\multicharts\\") import pardo_live_generic_v2_valentin reload(pardo_live_generic_v2_valentin) from pardo_live_generic_v2_valentin import * import os from os.path import exists import time import pickle import onnx from onnxruntime import InferenceSession print(f"*****************\t\t{__name__}\t\t*******************") #if __name__ != '__main__': # exit(-1) ''' # ORIGINAL WRAPPER #------------------ class MCWrapper: def init(self, file_model_predict: str, file_model_predict_prob: str): self.mode_predict = self.load_module(file_model_predict) self.mode_predict_prob = self.load_module(file_model_predict_prob) self.betsize_reserve = {} ''' import get_models reload(get_models) from get_models import get_models_from_dir class MCWrapper: def __init__(self): self.model_dic = None self.betsize_reserve = {} self.elktrades=0 self.flag_model_check=False def on_create(self, root_folder: str, models: str) -> bool: models_list = models.split(",") self.model_dic = {} self.opt = None for model in models_list: self.load_module(root_folder, model) return len(self.model_dic) > 0 def load_module(self, root_folder: str, model: str): # root_folder, model = get_models_paths() filename = root_folder + model if exists(filename): obj = None if model.find(".pkl") != -1: obj = pickle.load(open(filename, 'rb')) elif model.find(".onnx") != -1: obj = InferenceSession(filename) if obj is not None: self.model_dic[model] = obj ## ======================================= Hasbrook Kyle Amihud Lambda & VPIN ========================================== # done def main_function(self, metric: str, a_datetime: pd.DatetimeIndex, a_close: pd.Series, a_high: pd.Series, a_open: pd.Series, a_low: pd.Series, a_volume: pd.Series, a_dollar_volume: pd.Series, window: int, distribution: str, df: float): return MAIN_FUNCTION(metric, a_datetime, a2s(a_close), a2s(a_high), a2s(a_open), a2s(a_low), a2s(a_volume), a2s(a_dollar_volume), window, distribution, df).tolist() # NOTE That i have added an extra parameter called "name" which is passed from Multicharts to tell MC wrapper # which model to use from the dictionary of saved models ## ======================================= Get Weights FFD Function ========================================== # done def get_weights(self, d: float, thres: float) -> [float]: res = getWeights_FFD(d, thres) casted = np.reshape(res, len(res)).tolist() return casted ## ======================================= SciKit learn Model Prediction Functions ========================================== def model_check(self,name): if self.flag_model_check==False: if name not in self.model_dic.keys(): root_folder, model , zipexists = get_models_from_dir( name) self.load_module( root_folder , model ) self.flag_model_check=True if zipexists==True: os.remove(root_folder + model) else: self.flag_model_check=True return def model_predict(self, name , x , dt=1000 ): self.model_check(name) model = self.model_dic[name] return n2a(model_predict_v2(a2n(x), model, dt)) # done def model_predict_prob(self, name , x , dt=1000 ): self.model_check(name) model = self.model_dic[name] return n2a(model_predict_prob_v2(a2n(x), model, dt)) ## ======================================= Portfolio Optimization Functions from Portfoliolab ========================================== # to do in C def portfolio_opt_create(self, CLA1_NCO2_HRP3): self.opt_symbol_dic_price={} self.opt_symbol_dic_signal={} self.symboltoidx ={} self.opt = Portfolio_Opt_Create(CLA1_NCO2_HRP3) return def portfolio_opt_dump(self, symbol, trainp , datetimes): #datetimes=pd.to_datetime(datetimes) self.opt_symbol_dic_price[symbol] = pd.Series(trainp,index=datetimes,name=symbol) return def portfolio_opt_dump_signal(self, symbol,trainp, signal , datetimes): self.opt_symbol_dic_price[symbol] = pd.Series(trainp,index=datetimes,name=symbol) self.opt_symbol_dic_signal[symbol]= pd.Series(signal,index=datetimes,name=symbol) return def portfolio_opt(self, CLA1_NCO2_HRP3, solution ='max_sharpe', n_init=4 , use_signal=0 ): self.wts = Portfolio_Optimize_Main(self, CLA1_NCO2_HRP3 , solution = solution, n_init=n_init, use_signal=use_signal) r1 ,r2 = self.wts.columns.tolist(), self.wts.values[0] r2 = n2a(np.nan_to_num(r2)) return r1 ,r2 def portfolio_get_symbol_weight(self,symbol): return self.wts[symbol][0] #==================================================================================================================== # BELOW THIS ARE FUNCTIONS NEWLY ADDED #=========================ONNX MODEL PREDICTIONS ==================================================== # done def onnx_model_predict(self, x , name , dt=1000 ): self.model_check(name) model = self.model_dic[name] return n2a(Onnx_model_predict(a2n(x), model, dt)) # done def onnx_model_predict_prob(self, x, name , dt=1000 ): self.model_check(name) model = self.model_dic[name] (r1, r2, r3) = Onnx_model_predict_prob(a2n(x), model, dt) # return 3 arrays return n2a(r1), n2a(r2), n2a(r3) # done def onnx_model_predict_batch(self, name, x, x1, x2, x3, x4, x5): self.model_check(name) model = self.model_dic[name] return n2a(Onnx_model_predict_batch(np.vstack((a2n(x), a2n(x1), a2n(x2), a2n(x3), a2n(x4), a2n(x5))), model)) # done def onnx_model_predict_prob_batch(self, name, x, x1, x2, x3, x4, x5): self.model_check(name) model = self.model_dic[name] (r1, r2, r3) = Onnx_model_predict_prob_batch(np.vstack((x, x1, x2, x3, x4, x5)), model) return n2a(r1), n2a(r2), n2a(r3) # KALMAN FILTER # done def kalman_initiate(self , path_kalman): if os.path.exists(path_kalman)==False: os.mkdirs(path_kalman) try: self.kalman = Kalman(path_kalman); res = 100 # return 100 is passed except: res = -99# return -99 is passed return res # done def kalman_fit(self, symbol, VariableSeries): (r1, r2) = self.kalman.Fit(symbol, a2s(VariableSeries)) # typle of arrays return n2a(r1), n2a(r2) # NOTE that ValriableSeriesValue is a scalar value''' # done def kalman_update(self, symbol , VariableSeriesValue ): return self.kalman.Kalman_update( symbol, VariableSeriesValue) #--------------------------------------------------------------------------------------------------------------- # CHU AND SADF FROM ML FINLAB # done def chu_live(self, price, test_type): return n2a(Chu_live(a2s(price), test_type)) # done def sadf_live(self, logprice, n_jobs, sadf_min_length, model, sadf_lags, add_const, sadf_phi): return s2a(Sadf_live(a2s(logprice), n_jobs, sadf_min_length, model, sadf_lags, add_const, sadf_phi)) # ----------------------------------------------------------------------------------------------------- # MISC # NOTE THIS OUTPUTS 3 ARRAYS #def get_dfmind(self ,symbol, path_dfmind ,index_col): # return Getdfmind(symbol, path_dfmind ,index_col) # done def get_dfmind(self, symbol, path_dfmind, index_col): (rs1, r2, rs3) = Getdfmind(symbol, path_dfmind, index_col) return n2a(rs1), n2a(r2), n2a(rs3) # NOTE THIS OUTPUTS 1 SCALAR INTEGER AND 1 STRING # done def upload(self,filename): return Upload(filename) # PROP FIRM - ELK CAPITAL - SEND BROKER ORDERS - DO NOT MODIFY def upload_elk(self,filename): if self.elktrades>=1: return Upload_elk_continous(self.elk, filename) else: #self.elktrades==0 then Intitialize the broker plug in. self.elktrades = self.elktrades + 1 self.elk = Upload_elk_continous_init() return 0 , "Elk Broker Plugin Initalized" # done def get_betas(self, X, Y, outputarray_or_scalars=2): a1, a2 = Get_betas(a2n(X).reshape(-1, 1), a2n(Y), outputarray_or_scalars) return n2a_smart(a1), n2a_smart(a2) # BETSIZING # NOTE THIS FUNCTION OUTPUTS 1 dataframe with 2 columns # done def bet_size_probability_live_PY(self, events_index, t1, trgt, pt, sl, prob, num_classes, pred=None, step_size=0.0, average_active=False, num_threads=1): events_index = a2ns(events_index) t1 = a2ns(t1) trgt = a2n(trgt) pt = a2n(pt) sl = a2n(sl) prob = a2n(prob) pred = a2n(pred) res = Bet_size_probability_live_PY(events_index, t1, trgt, pt, sl, prob, num_classes, pred, step_size, average_active, num_threads) return s2a(res) ''' # NOTE THIS FUNCTION OUTPUTS 5 ARRAYS def bet_size_reserve_fit(self, symbol, events_index, t1, pred, fit_runs=100, epsilon=1e-5, factor=5, variant=2, max_iter=10000,num_workers=1): c_t, active_long , active_short , bet_size, params_list = Bet_size_reserve_fit(events_index, t1, pred, fit_runs=100, epsilon=1e-5, factor=5, variant=2, max_iter=10000,num_workers=1) self.betsize_reserve[symbol] = params_list return c_t, active_long , active_short , bet_size, params_list ''' # NOTE THIS FUNCTION OUTPUTS 5 ARRAYS # done def bet_size_reserve_fit(self, symbol, events_index, t1, pred, fit_runs=100, epsilon=1e-5, factor=5, variant=2, max_iter=10000, num_workers=1): events_index = a2ns(events_index) t1 = a2ns(t1) pred = a2n(pred) c_t, active_long, active_short, bet_size, params_list = Bet_size_reserve_fit(events_index, t1, pred, fit_runs=fit_runs, epsilon=epsilon, factor=factor, variant=variant, max_iter=max_iter, num_workers=num_workers) self.betsize_reserve[symbol] = params_list return n2a(c_t), n2a(active_long), n2a(active_short), n2a(bet_size), params_list # NOTE THIS FUNCTION OUTPUTS 4 ARRAYS # done def bet_size_reserve_get(self, symbol, events_index, t1, pred, params_list_mc): events_index = a2ns(events_index) t1 = a2ns(t1) pred = a2n(pred) try: params_list = self.betsize_reserve[symbol] except: params_list = params_list_mc c_t, active_long, active_short, bet_size = Bet_size_reserve_get(events_index, t1, pred, params_list) return n2a(c_t), n2a(active_long), n2a(active_short), n2a(bet_size) # MICROSTRUCTFEATURES # NOTE THIS FUNCTION OUTPUTS 2 ARRAYS # done def microstructfeatures_minutedata(self, date_time, price, volume, mapping='quantile', quantile_letters=26, sigma_dividor=256, batch_size=10000): date_time = as2n_datetime(date_time) price = a2n(price) volume = a2n(volume) # dump_type("date_time", date_time) # dump_type("price", price) # dump_type("volume", volume) # dump_type("mapping", mapping) # dump_type("quantile_letters", quantile_letters) # dump_type("simga_dividor", sigma_dividor) m1, m2 = Microstructfeatures_minute_live(date_time, price, volume, mapping, quantile_letters, sigma_dividor, batch_size) # dump_type("m1", m1) # dump_type("m2", m2) return m1, n2a(m2[0]) # NOTE THIS FUNCTION OUTPUTS 2 ARRAYS # done def microstructfeatures_tick(self, date_time, price, volume, mapping='quantile', quantile_letters=26, sigma_dividor=256, batch_size=10000): date_time = as2n_datetime(date_time) price = a2n(price) volume = a2n(volume) m1, m2 = Microstucture_feat_tick_live(date_time, price, volume, mapping, quantile_letters, sigma_dividor, batch_size) return m1, n2a(m2[0])

amw_775
Posts: 27
Joined: Apr 19 2020
Has thanked: 1 time
Been thanked: 18 times

Jul 22 2024

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...
tried this many times and unfortunetely it epically fails after running for a few hours.

HellGhostEvocatorX
Posts: 143
Joined: Feb 10 2022
Has thanked: 68 times
Been thanked: 23 times

Jul 22 2024

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.
Hey HellGhostEvocatorX

I have been through the same tiring excercise. ML.net wont work with MC.net because MCnet is built on .net framework 4.0 whereas ML.net requires .net Standard 2 + or .net Framework 5 and above if im not mistaken.

I was first calling Tensorflow from using tensorflow.net, numpy.net and all the .net supported packages via Multicharts.net but I would constantly run into Errors. FYI all the above .net packages are actually using C# and then calling Python.net and then calling the respective package such as tensorflow,numpy etc via Python.net

Finally I resorted to using the Python.net Package. You can call Python.net from Multicharts.net but you will again run into issues when you import packages like tensorflow, and numpy due to multi threading.

So now finally, I have a Multicharts.NET Python Class which allows you to call Python.NET succesfully. You can import any package you like from python and directly write the code inside Multicharts.Net Editor as if you are writing Python.
Ofocurse since I am a proffesional programmer and trader I am willing to sell the class and provide programming support and I can share the class with sample scripts. DM me if this of interest to
Thanks, I thought it was the framework.

I actually tried to integrate the other frameworks, but as written, without success.

Unfortunately, I don't know Python, even though it's on my long to-do list to learn it, so I don't know if the class you wrote would be right for me...

As written, I can write neural networks directly in C#, but these are then executed on the CPU, with Tensorflow they would be executed on the GPU. Since I don't know how to program graphics cards, the idea was to use Tensorflow There is also a .net library for this.

However, your written class should be very interesting for those who like to write in Python.

I would also be interested in your code, but only for learning purposes.

somewhat offtopic:
Since you are a professional programmer, I would be interested to know how you structure your code overall in multicharts.net?

1. you can't create direct class files (only via the Powerlanguage editor as an "empty" signal file) - that's so annoying...
2. mutlicharts.net uses signals and indicators and functions.
Signals to generate buy orders, indicators for drawings. I never actually use functions because they only have a limited number of possible return types - so I'd rather just write a method myself. Do you use these? Do you let your indicators and signals communicate? if yes how? -via global variables?

I would somehow like something more like the Model-view-model (MVVM) pattern, instead of a separate distinction between indicator/signal. In my opinion, functions are unnecessary.

Overall, I try my classes roughly in data preparation, data storage, drawings, purchase signals,
Logic (the actual calculation).

For very simple logic, the structure as specified in Multicharts.net is of course sufficient. For more complex logic, I don't think the current structure is that good - but maybe because I'm not a professional programmer and am missing something.

I'm currently working a lot on "best practice" and clean code, various design patterns, so the questions mentioned above come to mind.

Do you program complex logic and how/according to which system do you divide your code?