Examples: Interaction between MetaTrader 4 and Matlab via CSV Files

 

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

 

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

 
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
 

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

 
Nice work here, and very well laid out. This has saved me a ton of time setting up my system!
 

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

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