2. 結 果 の 画 面 テキスト(オブジェクト)を 表 示 する;OBJ_LABEL を 使 う 1.コード テキストを 表 示 する OBJ_LABEL は 表 示 位 置 の 指 定 に XY 座 標 (ピクセル); 左 上 が 原 点 を 使 う int init() ObjectCreat



Similar documents
スクリプトの 動 作 確 認 1.コード my_script_01.mq4 確 認 する 関 数 Comment,Print,Alert,MessageBox FileName=script_01.mq4 #include <WinUser32.mqh> MessageBox 用 #property

●70974_100_AC009160_KAPヘ<3099>ーシス自動車約款(11.10).indb

(C) 2011 amenbo the 3rd New MQL4(Build 600 以降 ); 基礎 ( その 1) インディケータを表示する アメンボです New_MQL4 では MQL5 類似の OOP(Object-oriented programming) が採用され

スライド 1

(C) 2011 amenbo the 3rd 擬似トレード提案 ( その 1) MT4/5 のストレテジー テスターのバックテスト機能は非常に強力ですが 幾つか不満があ ります その一つは 今表示されているリアルチャート上で EA を試したらどうなるかが良 く判らないことです アメンボが以前気に入

計算式の取り扱い

改訂版 :基本的な文字化の原則(Basic Transcription System for Japanese: BTSJ)

(Microsoft PowerPoint -

★分冊3-説明資料PDF用/02-PDF個別


™ƒŒì„³001†`028.pwd

76

' % % &! #


康乘聡子(P105‐121)/康乘聡子 p105‐121

‡Æ‡Ý‡©457_01-12

1級 ワンポイント

はじめにお読みください

工事記録写真チェックシステム 操作説明書

目 次 1. 論 理 関 数 IF IF の 概 要 論 理 式 の 種 類 等 号 不 等 号 具 体 的 な 使 い 方 ネスト 複 数 の 条 件 を 記 述...

intra-mart Accel Platform — ViewCreator ユーザ操作ガイド   第6版  

Lecture on

REALV5_A4…p_Ł\1_4A_OCF

untitled

「都市から地方への人材誘致・移住促進に関する調査」

<91498EE88CA D815B2E786C73>

〔 大 会 役 員 〕

橡本体資料+参考条文.PDF

情報処理技能検定試験 表計算2級 手順書

<4D F736F F D B67E05682E682E C8E313193FA834B F EF8ED FC90B382CC A548163>

購買ポータルサイトyOASIS簡易説明書 b

R4財務対応障害一覧


目 次 JAVIS Appli の 基 本 機 能... 3 JAVIS Appli について... 3 音 声 確 認 機 能 JAVIS Appli( 有 償 版 )の 機 能... 4 音 声 で 読 みの 確 認 をする... 4 辞 書 機 能... 5 単 語 を 登 録 する... 5

WEB版「新・相続対策マスター」(ご利用の手引き)

1. 機 能 概 要 CADデータ(DXF 形 式 )を 変 換 し EXCELに 図 形 として 表 示 します CADでのレイヤー 毎 に 表 示 / 非 表 示 や 線 分 の 属 性 ( 色 太 さ 等 )を 指 定 でき さらに 作 成 する 図 面 の 範 囲 大 きさを 指 定 できま

スライド 1

ThinkBoard Free60 Manual

<4D F736F F D208DEC90AC837D836A B81698F4390B394C5816A2E646F63>

   新潟市市税口座振替事務取扱要領

<4D F736F F D20819C486F70658F6F93588ED297708AC7979D89E696CA837D836A B E A2E646F63>

電子申告簡易マニュアル【所得税実践編】

第1回

KINGSOFT Office 2016 動 作 環 境 対 応 日 本 語 版 版 共 通 利 用 上 記 動 作 以 上 以 上 空 容 量 以 上 他 接 続 環 境 推 奨 必 要 2

Microsoft Word - TCⅡマニュアル_第6章_ doc

Microsoft Word - CiCAM Metal_操作マニュアル.doc

HYEC.ORGにおけるWinSCPの設定方法

<4D F736F F D F8D828D5A939982CC8EF68BC697BF96B38F9E89BB82CC8A6791E52E646F63>

Transcription:

<MQL4; 基 礎 の 確 認 (その2)> テキスト(オブジェクト)を 表 示 する;OBJ_TEXT を 使 う 1.コード テキストを 表 示 する OBJ_TEXT は&\ 示 位 置 の 指 定 に 日 時 と 価 格 を 使 う int init() ObjectCreate("myObj_1",OBJ_TEXT,0,0,0); int deinit() ObjectDelete("myObj_1"); スタート 関 数 ー------------------------------------------- int start() int と double は 自 動 で 文 字 に 変 換 される DoubleToStr(Close[0])はエラーになる string st=" 最 新 の 価 格 は "+Close[0]+" です "; ObjectSetText("myObj_1"," 表 示 できたか?",12,"M S ゴシック",Black); ObjectSetText("myObj_1",st,24,"MS ゴシック ",Black); ObjectMove("myObj_1",0,Time[10],(High[10]+0.05)); 1/16

2. 結 果 の 画 面 テキスト(オブジェクト)を 表 示 する;OBJ_LABEL を 使 う 1.コード テキストを 表 示 する OBJ_LABEL は 表 示 位 置 の 指 定 に XY 座 標 (ピクセル); 左 上 が 原 点 を 使 う int init() ObjectCreate("myObj_1",OBJ_LABEL,0,0,0); int deinit() ObjectDelete("myObj_1"); 2/16

スタート 関 数 ー------------------------------------------- int start() int と double は 自 動 で 文 字 に 変 換 される DoubleToStr(Close[0])はエラーになる string st=" 最 新 の 価 格 は "+Close[0]+" です "; ObjectSetText("myObj_1",st,24,"MS ゴシック ",Black); ObjectSet("myObj_1",OBJPROP_XDISTANCE,30); ObjectSet("myObj_1",OBJPROP_YDISTANCE,40); 2. 結 果 の 画 面 3/16

関 数 化 原 理 確 認 用 超 簡 単 な 配 列 の 授 受 4/16 メインから 関 数 に 配 列 を 渡 し 処 理 結 果 の 配 列 を 受 け 取 る 1.1 本 化 コード (1)コード 関 数 開 発 の 確 認 用 配 列 を 参 照 渡 しする 1 本 版 Script で 確 認 #property show_confirm 最 初 に1 回 止 める int init() ObjectCreate("myObj_1",OBJ_LABEL,0,0,0); int deinit() ObjectDelete("myObj_1"); void adseries(int n,int& series1[],int& series2[],int& result[]) int i; for (i = 0 ; i < n ; i++) result[i] = series1[i] + series2[i]; 結 果 を result に 格 納 スタート int start() int a[4]=10,20,30,40; int b[4]=50,60,70,80; int c[4];

adseries(4,a,b,c); Comment("Result:c[0]=",c[0],":c[1]=",c[1],":c[2]=",c[2],": c[3]=",c[3]); 文 字 サイズ 固 定 string st=" 計 算 結 果 : c[0]="+c[0]+" :c[1]="+c[1]+" :c[2]="+c[2]+" :c[3]="+c[3]; ObjectSetText("myObj_1",st,18,"MS ゴシック ",Black); ObjectSet("myObj_1",OBJPROP_XDISTANCE,30); ObjectSet("myObj_1",OBJPROP_YDISTANCE,40); (2) 結 果 のチャート 5/16

2. 分 割 コード( 関 数 化 ) (1)コード -1.メインコード mycall_series.mq4 関 数 開 発 の 確 認 用 配 列 を 参 照 渡 しする メイン; 分 割 版 #include <myhead.mqh> #property show_confirm 最 初 に1 回 止 める int init() ObjectCreate("myObj_1",OBJ_LABEL,0,0,0); int deinit() ObjectDelete("myObj_1"); スタート int start() int a[4]=10,20,30,40; int b[4]=50,60,70,80; int c[4]; adseries(4,a,b,c); Comment("Result:c[0]=",c[0],":c[1]=",c[1],":c[2]=",c[2],":c[3]=",c[3]); 文 字 サイズ 固 定 string st=" 関 数 化 の 計 算 結 果 : c[0]="+c[0]+" :c[1]="+c[1]+" :c[2]="+c[2]+" :c[3]="+c[3]; ObjectSetText("myObj_1",st,18,"MS ゴシック 6/16

",Black); ObjectSet("myObj_1",OBJPROP_XDISTANCE,30); ObjectSet("myObj_1",OBJPROP_YDISTANCE,40); -2.ヘッダファイル myhead.mqh myhead 確 認 用 ヘッダファイル \experts\include\ に 置 くこと #import "myfunctions.ex4" void mycomment(string com); void adseries(int n,int& series1[],int& series2[],int& result[]); #import -3.ライブラリ(ファイル) myfunctions.mq4 関 数 開 発 の 確 認 用 まず 現 在 の 終 値 を 表 示 する 簡 単 なコードを 関 数 化 する #property library void mycomment(string com) Comment(com); void adseries(int n,int& series1[],int& series2[],int& 7/16

result[]) int i; for (i = 0 ; i < n ; i++) result[i] = series1[i] + series2[i]; 結 果 を result に 格 納 (2) 結 果 の 画 面 8/16

ema の 関 数 化 9/16 移 動 平 均 線 ;ema をライブラリ( 関 数 )を 使 い Simple 化 する < 判 明 事 項 > SetIndexBuffer() などのインディケータの 設 定 が 1.コード 1ヘッダファイルに 記 述 すると 動 く OK 2ライブラリ( 関 数 )に 記 述 すると 動 かない NG (1)ヘッダファイル myhead.mqh ヘッダファイル \experts\include\ に 置 くこと #property indicator_buffers 7 SetIndexBuffer とは 異 なる 役 割? #import "myfunctions.ex4" void ema(double& line[],int PRICE,int period); void ema_(double& line[],double& source[],int period); int line4(double& line[],string st,int style,int colo,int w); #import ---- buffers double line0[2000]; double line1[2000]; 不 思 議 なことに line_1[]はダメで line_1[2000]などとするとokのことあり double line2[2000]; double line3[2000]; double line4[2000]; double line5[2000]; double histogram[2000]; static double source[2000];

---------------------------- void line0(string st,int style,int colo,int w) stylw,colo,w は 全 て int で 受 けること! SetIndexBuffer(0,line0); SetIndexLabel(0,st); SetIndexStyle(0, DRAW_LINE,style,w,colo); IndicatorDigits(Digits+2); SetIndexDrawBegin(0, 0); return; void line1(string st,int style,int colo,int w) stylw,colo,w は 全 て int で 受 けること! SetIndexBuffer(1,line1); SetIndexLabel(1,st); SetIndexStyle(1, DRAW_LINE,style,w,colo); IndicatorDigits(Digits+2); SetIndexDrawBegin(1, 0); return; void line2(string st,int style,int colo,int w) stylw,colo,w は 全 て int で 受 けること! SetIndexBuffer(2,line2); SetIndexLabel(2,st); SetIndexStyle(2, DRAW_LINE,style,w,colo); IndicatorDigits(Digits+2); SetIndexDrawBegin(2, 0); return; void histogram(string st,int style,int colo,int w) stylw,colo,w は 全 て int で 受 けること! SetIndexBuffer(6,histogram); SetIndexLabel(6,st); SetIndexStyle(6, DRAW_HISTOGRAM,style,w,colo); IndicatorDigits(Digits+2); SetIndexDrawBegin(6, 0); 10/16

return; (2)ライブラリ; 関 数 ライブラリ myfunctions.mq4 #property library void ema(double& line[],int PRICE,int period) static double ema[2000]; for(int j=0;j<1000;j++) ema[j]=ima(null, 0, period,0,mode_ema,price, j); ArrayCopy(line,ema); return; void ema_(double& line[],double& source[],int period) static double ema_[2000]; ArraySetAsSeries(source,true); for(int j=0;j<1000;j++) ema_[j] = imaonarray(source, 0, period, 0, MODE_EMA, j); ArrayCopy(line,ema_); 11/16

return; /* 再 度 試 してみること int line4(double& line4[],string st,int style,int colo,int w) stylw,colo,w は 全 て int で 受 けること! IndicatorBuffers(2);ライン 計 算 が1 個 なら 1 でよい SetIndexBuffer(0,line4); SetIndexLabel(0,st); SetIndexStyle(0, DRAW_LINE,style,w,colo); IndicatorDigits(Digits+2); SetIndexDrawBegin(0, 0); int err=getlasterror(); return(err); */ ----------------------------------------------------------------------- (3)メインコード return_array_02_2.mq4 移 動 平 均 return_array_02_2.mq4 +------------------------------------------------------------------+ #include <myhead.mqh> #include <stdlib.mqh>エラー 解 析 用 #property indicator_chart_window extern int period = 15; int init() ---- indicators IndicatorBuffers(10); line0("myima_0",style_dash,red,1); line1("myima_1",style_solid,blue,1); ---- 12/16

ObjectCreate("myObj_1",OBJ_LABEL,0,0,0); +------------------------------------------------------------------+ int deinit() ---- ObjectDelete("myObj_1"); ---- +------------------------------------------------------------------+ int start() int counted_bars=indicatorcounted(); ---- ema(line0,price_close,period); ArraySetAsSeries(source,true); for(int i=0;i<200;i++) source[i]=low[i]; ema_(line1,source,period); string st_=" : line0[30]="+line0[30]+" : line1[30]="+line1[30]; ObjectSetText("myObj_1",st_,10,"MS ゴシック ",Black); ObjectSet("myObj_1",OBJPROP_XDISTANCE,20); ObjectSet("myObj_1",OBJPROP_YDISTANCE,40); ---- +------------------------------------------------------------------+ 13/16

2. 結 果 の 画 像 14/16

縦 線 を 連 続 して 描 く 条 件 が 合 致 した 場 合 に 縦 線 を 描 く 方 法 1.コード V_Line.mq4 #property indicator_chart_window int init() for(int i=0;i<=500;i=i+100) string ad=i; ObjectCreate("V_Line"+ad,OBJ_VLINE,0,Time[i],0); int deinit() for(int i=0;i<=500;i=i+100) string ad=i; ObjectDelete("V_Line"+ad); +------------------------------------------------------------------+ int start() int counted_bars=indicatorcounted(); ---- for(int i=0;i<=500;i=i+100) string ad=i; ObjectSet("V_Line"+ad,OBJPROP_TIME1,Time[i]); 15/16

---- +------------------------------------------------------------------+ 2. 結 果 のチャート 以 上 16/16