FX MetaTrader 4 Linuxで動かしてみる | syululilaのぶろぐ

syululilaのぶろぐ

いろんなこと 覚書もろもろ

今利用中のMT4を、GBP/JPY専用で使い

USD/JPY EUR/JPY GBP/USD EUR/USD を
別のMT4で、別画面で表示させてチラ見したいと思い 
何か良い方法がないか 色々考えていました~

常用しているPCは
Windows Desktop PC(そこそこスペック) & ワイドモニタ
Linux Desktop PC(ポンコツスペック) & モニタ

WindowsPCにビデオカード増設してモニタを増やすと 
手間もコストもかかり、場所もとるので
今ある環境の中で構築したいので...........

WindowsPCの画面出力を TVの大画面へ 
参考 パソコン画面をテレビに出力させる方法 とも考えましたが
まーまー 何もそこまでしなくても (^_^;) と思いとどまり

Linux仕様のMT4のソースを探したところ見つからず............ふりむきひよこ

Linuxに VMware をインストールして 
さらに WindowsOSを、VMにインストールして 
MT4動かすのもめんどうだし
ポンコツPCなので リソース足りないしー

ぐぐってみたところ~
すばらしい 使い方をしている方々を 発見

* FXとコンピュータ/FedoraでMetaTrader4を動かす
** 今回こちらのサイトに掲載されている手順を参考にさせていただきました
* SnowLeopardやUbuntuにWine Betaを入れてMT4とかを動かしてみるメモ
* 「WINE」インストール方法

なので 早速 LinuxにMT4のsetupしてみました~音譜

結果 
まだまだ改善の余地はありますが
チラ見 環境は getできたので 良かったでーす うへ

以下は今回行った手順です
覚書なので ご参考程度にお読みください サンプル百貨店



MT4をLinuxで動かしてみる

1. 仕様(PCスペックとディストリビューション)

2. wineのインストール(yum経由)
3. ライブラリ(mfc42.dll)の追加
4. GUIでのwineのconfigure
5. MT4のインストール
6. 動作確認
7.使用中のIndicatorsを、WindowsPCからcygwin(Poderosa)経由でscp(おまけ)
8. Windowsからリモート接続(おまけ)



1.仕様(PCスペックとディストリビューション)

MemTotal: 643072 kB
CPU model name: AMD Athlon(tm) XP 2400+
Distribution: CentOS release 5.4(Final)



2.wineのインストール

Linuxにて
yumの設定にリポジトリDagを追加する(root権限)
%% touch /etc/yum.repo.d/dag.repo

%% vi /etc/yum.repo.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag/
enabled=1
gpgcheck=0
* enabled=1に設定すると yumコマンド実行時にDagのrepoも探しに行く
** 但し updateの時にDLされるバイナリが増えてしまうので空容量に要注意
* enabled=0に設定すると yumコマンド実行時にオプション --enablerepo=dagをつけてrepo指定する
* どちらかお好でお選びください 詳細は man yum

yum経由のインストール(enabled=1に設定)
%% yum install wine

インストールされたか確認する
%% rpm -qa | grep wine
wine-core-1.0.1-1.el5.rf
wine-1.0.1-1.el5.rf
wine-nas-1.0.1-1.el5.rf
wine-jack-1.0.1-1.el5.rf
wine-capi-1.0.1-1.el5.rf
wine-twain-1.0.1-1.el5.rf
wine-ldap-1.0.1-1.el5.rf
wine-esd-1.0.1-1.el5.rf
wine-cms-1.0.1-1.el5.rf

他のディストリビューションのインストール方法、ソースについては
WineBinaryDownloads  を、ご参照ください



3.ライブラリ(mfc42.dll)の追加

Downloadthe dll file mfc42.dll for free!
のClick Here to Download mfc42.dll より 
ブラウザ経由で/tmpへDL(wgetはできなかったです)

ユーザのホームディレクトリ(今回はroot) .wine/drive_c/windows/system32にコピー
%% cd
%% ls -la | grep .wine
drwxr-xr-x 4 root root 4096 4月 16 22:32 .wine



ディレクトリ構成を確認してみる
%% ls -la .wine/
drwxr-xr-x 4 root root 4096 4月 16 22:32 .
drwxr-x--- 26 root root 4096 4月 17 14:41 ..
-rw-r--r-- 1 root root 11 4月 1223:36 .update-timestamp
drwxr-xr-x 2 root root 4096 4月 12 23:36dosdevices
drwxr-xr-x 4 root root 4096 4月 12 23:36 drive_c
-rw-r--r-- 1 root root 429603 4月 16 22:32 system.reg
-rw-r--r-- 1 root root 15892 4月 16 22:32 user.reg
-rw-r--r-- 1 root root 2346 4月 16 22:32userdef.reg

%% cd .wine/drive_c/windows/system32
%% cp /tmp/mfc42.dll ./
%% ls -la | grep mfc42.dll
-rw-r--r-- 1 root root 995383 4月 12 23:40 mfc42.dll



4.GUIでのwineのconfigure

1. アプリケーション->システムツール->Wine Configuration をクリック
2. ライブラリタブをクリック ->新規ライブラリオーバーライトに mfc42.dll と入力し->適用
3. オーディオタブをクリック ->DirectSoundのハードウェアアクセラレーションを Emulationにし ->適用,OK



5.MT4のインストール

MetaTrader4 のサイト内の DownloadMetaTrader 4より
/tmp にwget ->インストール
%% cd /tmp
%% wget http://www.metatrader4.com/files/mt4setup.exe

%% wine mt4setup.exe
完了するとデスクトップにアイコンができました

インストールされたMT4のディレクトリ構成を確認してみる
%% ls -la .wine/drive_c/Program\ Files/MetaTrader\ 4/
合計 5580
drwxr-xr-x 15 root root 4096 4月 12 23:41 .
drwxr-xr-x 5 root root 4096 4月 12 23:41 ..
-rw-r--r-- 1 root root 15872 10月 15 2007DDE-Sample.xls
-rw-r--r-- 1 root root 25069 4月 12 23:41INSTALL.LOG
-rwxr-xr-x 1 root root 66288 3月 24 16:37LiveUpdate.exe
-rw-r--r-- 1 root root 60864 3月 24 16:38MetaEditor.chm
-rwxr-xr-x 1 root root 1073280 3月 24 16:38 MetaEditor.exe
-rwxr-xr-x 1 root root 1239760 3月 24 16:38 MetaLang.exe
-rw-r--r-- 1 root root 299416 3月 24 16:38 Terminal.chm
-rw-r--r-- 1 root root 336841 3月 24 16:38Terminal_russian.chm
-rwxr-xr-x 1 root root 211968 3月 25 02:31Uninstall.exe
drwxr-xr-x 2 root root 4096 4月 13 18:27config
drwxr-xr-x 2 root root 4096 4月 13 18:36deleted
drwxr-xr-x 12 root root 4096 4月 13 18:13 experts
drwxr-xr-x 15 root root 4096 4月 13 18:46 history
-rw-r--r-- 1 root root 950 4月 1223:41 install.sss
drwxr-xr-x 2 root root 4096 4月 12 23:41languages
drwxr-xr-x 2 root root 4096 4月 12 23:41links
drwxr-xr-x 2 root root 4096 4月 17 01:12logs
drwxr-xr-x 2 root root 4096 4月 16 22:32mailbox
-rw-r--r-- 1 root root 71232 3月 24 16:38metaeditor_russian.chm
drwxr-xr-x 7 root root 4096 4月 13 20:47profiles
drwxr-xr-x 2 root root 4096 4月 12 23:41sounds
drwxr-xr-x 2 root root 4096 4月 12 23:41symbolsets
drwxr-xr-x 2 root root 4096 4月 12 23:41templates
-rwxr-xr-x 1 root root 1907208 3月 24 16:40 terminal.exe
-rw-r--r-- 1 root root 273098 3月 24 16:38terminal_Chinese (Simplified).chm
drwxr-xr-x 6 root root 4096 4月 12 23:43tester




6. 動作確認

デスクトップにできたMT4のアイコンをクリックして起動
MT4の初期設定行います

画面はこんな感じです

davaのぶろぐ






7.使用中のIndicatorsを、WindowsPCから cygwin  (Poderosa )経由でscp(おまけ)

※ 一部パラメータの変更できないインジケータがありました(未解決)ので、参考程度にお読みください

Windows Cgwin(Poderosa )にて
--------------
win path
C:\Program Files\MetaTrader 4\experts\indicators
cygwinの/tmpにコピーしておく

tar.gzにして 
コピー & 誰でも使えるように アクセス権を変えておく
$ cd /tmp
$ tar cfzv indicator.tar.gz indicators
$ ls -la | grep indicator.tar.gz
$ -rw-r--r-- 1 dava None 209311 Apr 13 17:12 indicators.tar.gz

$ scp dava@192.168.xx.xx:/tmp indicators.tar.gz
dava@192.168.xx.xx's password:
indicators.tar.gz 100% 204KB 204.4KB/s 00:00

* USBストレージを使ってのコピーでもOKです


Linuxにて
--------------
今回はroot権限で作業
/tmpにコピーしたWindowsのindicators.tar.gz を MetaTraderのパスへコピーする
%% cp /tmp/indicators.tar.gz .wine/drive_c/Program\Files/MetaTrader\4/experts/
%% cd .wine/drive_c/Program\ Files/MetaTrader\ 4/experts/

既存のindicatorsフォルダをバックアップして 差し替える
%% mv indicators indicators_bak
%% ls
MACD Sample.ex4 bak_indicators indicators.tar.gz presets
MACD Sample.mq4 files libraries samples
Moving Average.ex4 include logs scripts
Moving Average.mq4 mqlcache.dat templates

既存のindicatorを Windowsで利用中のindicatorに差し替える
%% tar xvzf indicators.tar.gz
%% ls -la
drwxr-xr-x 12 root root 4096 4月 13 18:13 .
drwxr-xr-x 15 root root 4096 4月 12 23:41 ..
-rw-r--r-- 1 root root 5540 4月 12 23:41 MACD Sample.ex4
-rw-r--r-- 1 root root 5607 10月 15 2007 MACD Sample.mq4
-rw-r--r-- 1 root root 4736 4月 12 23:41 Moving Average.ex4
-rw-r--r-- 1 root root 4738 10月 15 2007 Moving Average.mq4
drwxr-xr-x 2 root root 4096 4月 12 23:42 bak_indicators
drwxr-xr-x 2 root root 4096 4月 12 23:41 files
drwxr-xr-x 2 root root 4096 4月 12 23:41 include
drwxr-xr-x 2 dava 513 4096 4月 13 17:11 indicators
-rw-r--r-- 1 root root 209311 4月 13 18:08 indicators.tar.gz
drwxr-xr-x 2 root root 4096 4月 12 23:42 libraries
drwxr-xr-x 2 root root 4096 4月 12 23:43 logs
-rw-r--r-- 1 root root 660 4月 12 23:41 mqlcache.dat
drwxr-xr-x 2 root root 4096 4月 12 23:41 presets
drwxr-xr-x 5 root root 4096 4月 12 23:41 samples
drwxr-xr-x 2 root root 4096 4月 12 23:42 scripts
drwxr-xr-x 2 root root 4096 4月 12 23:41 templates

もしも indicatorが使えなければ アクセス権を変更しておく
%% chmod -R 777 /indicators




8.Windowsからリモート接続(おまけ)

* 今回はrootユーザを設定しています
* 常用する場合は、セキュリティ上ユーザ毎に追加設定を行ってください

Serverの設定(Linux)
------------------------

インストール状況の確認
%%rpm -qa | grep vnc
vnc-4.1.2-14.el5_3.1
gtk-vnc-0.3.8-3.el5
vnc-server-4.1.2-14.el5_3.1
gtk-vnc-python-0.3.8-3.el5

設定ファイルの編集
%% cp /etc/sysconfig/vncservers /etc/sysconfig/bak-vncservers

%% vi /etc/sysconfig/vncservers
VNCSERVERS="1:root"
VNCSERVERARGS[2]="-geometry 800x600"
* ユーザが一人(rootのみ)なので、ディスプレイ番号1:root
* ユーザが増えたら、ユーザ名:ディスプレイ番号 を追加する
** 例) VNCSERVERS="1:root 2:admin 3:hoge 4:hage"

パスワード設定
%% vncpasswd
Password:
Verify:

ファイアーウォール(iptables/SELinux)を有効にしている場合は
設定ファイル(/etc/sysconfig/iptables)に直接ルールを追加 ->iptablesの再起動
%% cp /etc/sysconfig/iptables /etc/sysconfig/bak-iptables

%% vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport XX-jACCEPTINPUT
の下に、ルールに以下を追加する↓

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport5900-j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport5901-j ACCEPT

%% service iptables restart

* ユーザが一人(rootのみ)なので、5901ポートのみ追加
* ユーザが増えたら、5900+ディスプレイ番号のポートを追加する
** 例) 5902 接続時のディスプレイ番号2
*** -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp--dport5902 -j ACCEPT
** 例) 5903 接続時のディスプレイ番号3
*** -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp--dport5903 -j ACCEPT

サービスの起動
%% service vncserver start

デフォルトで起動するウィンドウマネージャtwmから、GNOMEへ変更する
.vnc/xstartupを編集
%% cd
%% vi .vnc/xstartup

# & twm
gnome-session &

サービスの再起動
%% service vncserver restart



Clientの設定(Windows)
------------------------

1. VNCfeatureComparisonAndDownloadSelector から実行ファイルをDLして、インストールする

2. スタート→全てのプログラム→RealVNC→VNCViewer4→RunVNCViewerからクライアントソフトを起動する

3. Serverの欄に、"接続先のIPアドレス:ディスプレイ番号" を入力しOKをクリック
 接続できない場合は、Linuxの システム->管理->セキュリティレベルとファイヤーウォールの設定->ファイヤーウォールのオプション->その他のポートに 5901ポートを追加してください

4. パスワード認証画面で、サーバにてvncpasswdで作成したパスワードを入力し、OKをクリックします

5. VNCからリモート接続後の画面です

davaのぶろぐ




MetaTraderをクリックして起動します


davaのぶろぐ






参考URL

* 「WINE」インストール方法
* WINE HQ
* wineパッケージのインストール/yum
* Downloadthe dll file mfc42.dll for free!
* VNCfeatureComparisonAndDownloadSelector

*
MetaTrader4
* man yum

* WindowsでLinuxをリモート操作(前編)