また、DWTHarrのMQL5仕様の作成を依頼されましたが、途中で心が折れてしまったのでインジケーター指標として表示することができませんでした。サンプルとしてコメント表示のコードを掲示しておきますので試してみてください。(オブジェクト表示なら可能だと思います。)
- //+------------------------------------------------------------------+
- //| DWTHarr.mq5 |
- //| Copyright 2010, bighope |
- //| http://expertadviser-bighope.blogspot.com/ |
- //+------------------------------------------------------------------+
- #property copyright "Copyright 2010, bighope"
- #property link "http://expertadviser-bighope.blogspot.com/"
- #property version "1.00"
- #property indicator_separate_window
- #property indicator_buffers 1
- #property indicator_plots 1
- #property indicator_color1 Red
- input int N = 7;//対象データ数(2のN乗)
- input int HBs = 3;//高周波カット位置
- input int LBs = 4;//低周波カット位置
- input int Shift = 0;//データのシフト数
- int DWTPeriod;
- //---------buffers
- double IDWT[];
- double g[];
- double gs[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- //--- indicator buffers mapping
- SetIndexBuffer(0,IDWT,INDICATOR_DATA);
- //ArraySetAsSeries(IDWT,false);
- PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
- DWTPeriod = MathPow(2,N);
- ArrayResize(g,DWTPeriod);
- ArrayResize(gs,DWTPeriod);
- ZeroMemory(g);
- ZeroMemory(gs);
- //---
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int OnCalculate(const int rates_total,//Priceバッファ数
- const int prev_calculated,//処理バー数
- const int begin,//重要なデータが始まる所
- const double &price[])
- {
- //---
- //PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,rates_total-DWTPeriod-1);
- string text;
- int k;
- int DWTf,z;
- double sum,difference;
- for(k=0;k<DWTPeriod;k++)g[k] = price[rates_total-k-Shift-1];
- DWTf = DWTPeriod/2;
- //変換
- for(z=1;z<=N;z++)
- {
- for(k=0;k<DWTf;k++)
- {
- sum =(g[k*2]+g[k*2+1])/2;
- difference =(g[k*2]-g[k*2+1])/2;
- gs[k] =sum;
- if((LBs>=z)&&(z>=HBs)){gs[DWTf+k] = difference;}else{gs[DWTf+k] = 0;}//フィルタリング作業
- }
- ArrayCopy(g,gs);
- if(N>z) DWTf =DWTf/2;
- }
- //逆変換
- for(z=1; z<=N ;z++)
- {
- for(k = 0; k < DWTf; k++)
- {
- sum = g[k]+g[k+DWTf];
- difference = g[k]-g[k+DWTf];
- gs[2*k] = sum;
- gs[2*k+1] = difference;
- }
- ArrayCopy(g,gs);
- if(N>z)DWTf =2*DWTf;
- }
- for(k=0;k<DWTPeriod;k++){ IDWT[rates_total- Shift-k-1] = g[k];text += DoubleToString(g[k])+"\n";}
- // for(k=DWTPeriod;k>0;k--){ IDWT[rates_total- Shift-k] = g[k-1]; }
- //--- return value of prev_calculated for next call
- Comment(text);
- return(rates_total);
- }
- //+------------------------------------------------------------------+
1 件のコメント :
DWThaarをMQ5で使用できるかトライして頂きまして、有難う御座いました。
また、ATC2010に参加中のお忙しい中、お時間を割いて頂きました事、合わせてお礼申し上げます。
ATC2010でのご活躍、お祈り申し上げます。
コメントを投稿