LoginSignup
3
1

More than 5 years have passed since last update.

MQL on Vim ( VimでMQLをかいてみる )

Last updated at Posted at 2018-05-29

Summary

MQLという言語をVimで書いて実行する環境を作ってみましたっ

foo.gif

Thanks

// twitter
@haxe
@matthn
@raa0121

Environment

$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.13.3
BuildVersion:   17D47

$ wine --version
wine-3.0

$ mono --version
Mono JIT compiler version 5.4.1.6 (tarball Mon Dec 11 14:59:42 GMT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            sgen (concurrent by default)


$ wine cmd
Microsoft Windows 10.0.15063 (3.0)

Z:\Users\callmekohei\.config\>

MetaEditorに F5 を送る

こんな感じ(F#という言語で書いてます)

abc.fsx
open System.Runtime.InteropServices
open System.Windows.Forms

[<DllImport "user32.dll">]
extern nativeint FindWindow(string className, string windowName)

[<DllImport "user32.dll">]
extern bool SetForegroundWindow(nativeint hwnd)

FindWindow("MetaQuotes::MetaEditor::5.00", null) |> SetForegroundWindow |> ignore
SendKeys.Send "{F5}"

Quickrunの設定とBash script

 let g:quickrun_config.mql4 = {
        \  'exec': [ '%c %o %s:p:t' ]
        \ ,'command':'bash'
        \ ,'cmdopt' :'$HOME/tmp/quickrunMQL/quickrunMQL.bash'
    \}

^Mctrl V -> ctrl M で入力する

foo.bash
# ===========================================================================
#  FILE    : foo.bash
#  AUTHOR  : callmekohei <callmekohei at gmail.com>
#  License : MIT license
# ===========================================================================

file=$1
MetaTraderHOME=("$WINEPREFIX/drive_c/Program Files/OANDA - MetaTrader")
MetaEditor=("${MetaTraderHOME[@]}"/metaeditor.exe)
SendsKeyCMD=$(cd $(dirname $0) && pwd)/quickrunMQL

wine "${MetaEditor[@]}" /s /log:foo.log /compile:$file 2>/dev/null
iconv -f utf-16 -t utf-8 foo.log | sed -e "s/^M//g" > bar.log

echo "───── MetaEditor Compiler ─────"
cat bar.log

if cat bar.log | fgrep 'Result 0 error(s), 0 warning(s)' 1>/dev/null ; then

    echo "───── MetaTrader Terminal ─────"
    echo $SendsKeyCMD | wine cmd 1>/dev/null
    echo $SendsKeyCMD | wine cmd 1>/dev/null
    echo $SendsKeyCMD | wine cmd 1>/dev/null
    cat "${MetaTraderHOME[@]}"/MQL4/Logs/$(date +"%Y%m%d").log | tail -4 | sed -e "s/\\^M//g"

fi

rm foo.log
rm bar.log

課題

とりあえず動く、という程度なのでもっと洗練させたい

TODO: 2018/05/29
もうすこしわかりやすく書く!
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1