MT4用のDLLを作成したく
http://fx-dollaryen.seesaa.net/article/390157441.html
上記のサイトを参考にDLLを作成してみました。
手順通りnuget.orgからUnmanaged Exportsをインストール
X86と.net4に設定もしてMT4を実行してみました。
結果は、MetaEditorで緑色の再生ボタンを実行
ウィンドウ開く
設定画面でDLLの使用を許可にcheck
OKを押したら画面が閉じてしまいます。
実行環境
Windows10
VS2019
試したこと
Comment(Plus(3,3));
のコードより前にアラートの関数を置くと
一瞬だけ音が鳴るので、一瞬は、動作して
Plusの所でウィンドウが落ちていると推測まではしているのですが・・・
ココからのどういう風にアプローチしてよいのか?
わかりません。
知りたい事
参考ブログと環境が違いますが
VS2019のC#でMT4のDLLを作成したい
VS2019でC#でクラスを作成するプロジェクトが複数あるのですがドレを使うのが正解ですか??
C#
1using System; 2using System.Text; 3using RGiesecke.DllExport; 4using System.Runtime.InteropServices; 5 6namespace mt4_dll_test3 7{ 8 public class Class1 9 { 10 [DllExport("Plus", CallingConvention = CallingConvention.StdCall)] 11 public static int Plus(int left, int right) 12 { 13 return left + right; 14 } 15 } 16} 17コード
mql4
1//+------------------------------------------------------------------+ 2//| test2.mq4 | 3//| Copyright 2019, MetaQuotes Software Corp. | 4//| https://www.mql5.com | 5//+------------------------------------------------------------------+ 6#property copyright "Copyright 2019, MetaQuotes Software Corp." 7#property link "https://www.mql5.com" 8#property version "1.00" 9#property strict 10#property indicator_chart_window 11//+------------------------------------------------------------------+ 12//| Custom indicator initialization function | 13//+------------------------------------------------------------------+ 14#import "mt4-dll-test3.dll" 15 int Plus(int left, int right); 16#import 17//+------------------------------------------------------------------+ 18//| Custom indicator initialization function | 19//+------------------------------------------------------------------+ 20int OnInit() 21 { 22//--- indicator buffers mapping 23 Comment(Plus(3,3)); 24Alert("test"); 25 26//--- 27 return(INIT_SUCCEEDED); 28 } 29//+------------------------------------------------------------------+ 30//| Custom indicator iteration function | 31//+------------------------------------------------------------------+ 32int OnCalculate(const int rates_total, 33 const int prev_calculated, 34 const datetime &time[], 35 const double &open[], 36 const double &high[], 37 const double &low[], 38 const double &close[], 39 const long &tick_volume[], 40 const long &volume[], 41 const int &spread[]) 42 { 43//--- 44 45//--- return value of prev_calculated for next call 46 return(rates_total); 47 } 48//+------------------------------------------------------------------+ 49
あなたの回答
tips
プレビュー