Examples: Interaction between MetaTrader 4 and Matlab via CSV Files

MetaQuotes
Moderator
225493
MetaQuotes  

New article Interaction between MetaTrader 4 and Matlab via CSV Files has been published:

Step-by-step instructions of how to organize data arrays exchange between MetaTrader 4 and Matlab via CSV files.

Now let us check how everything works. Let us try to enable and disable the timer using “Start”. If the timer is enabled, the clock above the path input field must function.

It would be more correct to delete the timer using the "X" button at closing of GUI. If you want to do so, add

stop(handles.t) ; % stop the timer
delete(handles.t); % delete the timer

at the beginning of function “figure1_CloseRequestFcn”. This function will be called at closing of GUI. You can access to it from GUI editor:

But, please take into consideration that now, if you press “Run” of the editor without having closed the operating GUI, the old timer will not be deleted while the new one will be created. And next time there will be one more created, etc. You can deal with "unsettled" timers using command “delete(timerfind)” from the Matlab console.

Author: Dmitriy

[Deleted]  

I used a system similar to this with mqII v.3 to connect AmiBroker and Meta Trader together. The reason was the limited functionality of v3 indicator builder. Both MT and AB could have the same file open at the same time, something that you can not do with eXcell or most of MS software. I didnot delete the file in between read writes. What I did was to place a switch on the first line of the file too indicator if data contained in it was new unread or old alread read data. This switch was reset only after all the data was writen to it, so MT would not get bad or partial signal information. Basicly what I did was to use AB to process all data generate from MT generate signals and pass back the results to MT. Which would place and manage the orders. Worked very well.

The CockeyedCowboy

[Deleted]  
CockeyedCowboy:

I used a system similar to this with mqII v.3 to connect AmiBroker and Meta Trader together. The reason was the limited functionality of v3 indicator builder. Both MT and AB could have the same file open at the same time, something that you can not do with eXcell or most of MS software. I didnot delete the file in between read writes. What I did was to place a switch on the first line of the file too indicator if data contained in it was new unread or old alread read data. This switch was reset only after all the data was writen to it, so MT would not get bad or partial signal information. Basicly what I did was to use AB to process all data generate from MT generate signals and pass back the results to MT. Which would place and manage the orders. Worked very well.

The CockeyedCowboy


Can this method work in backtesting? I doubt if the data can be exchanged between Matlab and MT4 via CSV file in backtesting. Anybody with similar experience pls comment, thanks
[Deleted]  

Dmitriy

nice article. Have you tried calling DLL compiled from matlab code in MQ4? I did not have any luck, just getting uninit reason 1 without any output fropm the dll function...

[Deleted]  
Nice work here, and very well laid out. This has saved me a ton of time setting up my system!
Rodra Gon
13
Rodra Gon  

Great job, i'll use this way to feed my neurral network in Matlab...

Guo Wei Long
192
Guo Wei Long  
the last bar must be rewrite
oxarbitrage
152
oxarbitrage  
thank you very much for this article. it works perfect, i am on my way to apply my matlab strategies live into metatrader.