MT4インジケータ ADXm

このQ&Aのポイント
  • ADXmは、右肩上がり、右肩下がりの動きをするプログラムです。
  • ADXmの色の変化の際に条件を行うためには、プログラムを変更する必要があります。
  • 具体的な変更内容について、MT4プログラミングの詳しい方に教えてもらいたいです。
回答を見る
  • ベストアンサー

MT4インジケータ ADXm

下記は、ADXmのプログラムなのですが、ADXmは、基本的に右肩上がり、右肩下がりの動きをします。右肩上がり、下がりでは、ラインの色が違うのですが、この色の変化の際(上がり、下がりの変化)の際に下記の条件を行うには、どのようにプログラムを変更すればよいのでしょうか。 どなたかMT4のプログラミングに詳しい方、ご教授ください。 (1)Alertを鳴らす (2)Soundを一度鳴らす (3)Soundを鳴らし続ける //-------ANG3110@latchess.com------- //**************************************** #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 White #property indicator_color2 DeepPink #property indicator_color3 DeepSkyBlue #property indicator_color4 Goldenrod #property indicator_color5 Goldenrod #property indicator_width2 2 #property indicator_width3 2 #property indicator_style4 0 #property indicator_style5 0 #property indicator_level1 0 //===================================== extern int p=14; extern int Level=25; //===================================== double ADX[],ADXL[],DI[],levh[],levl[]; double dh,dl,tr,H,L,num1,num2,num3,dhk,dlk,div; double zdh,zdhp,zdl,zdlp,zdx,zdxp,zdhl,si; double temp,ki; int fs,fss,ti; //********************************************************* int init() { IndicatorShortName("ADXm "+"("+p+")"); //-------------------- SetIndexBuffer(0,DI); SetIndexBuffer(1,ADX); SetIndexBuffer(2,ADXL); SetIndexEmptyValue(2,0.0); SetIndexBuffer(3,levh); SetIndexBuffer(4,levl); //-------------------- return(0); } //********************************************************* int start() { int cbi,IC=Bars-IndicatorCounted()-1; if (IC<10) cbi=IC; else { cbi=Bars-2; ki=2.0/(p+1); ADX[cbi+1]=0.0; ADXL[cbi+1]=0.0; zdhp=0.0; zdh=0.0; zdlp=0.0; zdl=0.0; zdxp=0.0; zdx=0.0; ti=Time[cbi]; fs=0; fss=0; } //------------------------------------------------- for (int i=cbi; i>=0; i--) { if (ti!=Time[i]) {zdhp=zdh; zdlp=zdl; zdxp=zdx; ti=Time[i];} H=High[i]; L=Low[i]; dh=H-High[i+1]; dl=Low[i+1]-L; if(dh<0) dh=0; if(dl<0) dl=0; if(dh==dl) {dh=0; dl=0;} else if(dh<dl) dh=0; else if(dl<dh) dl=0; num1=MathAbs(H-L); num2=MathAbs(H-Close[i+1]); num3=MathAbs(L-Close[i+1]); tr=MathMax(MathMax(num1,num2),num3); if(tr==0) {dhk=0; dlk=0;} else {dhk=100.0*dh/tr; dlk=100.0*dl/tr;} zdh=zdhp+(dhk-zdhp)*ki; zdl=zdlp+(dlk-zdlp)*ki; zdhl=zdh-zdl; DI[i]=zdhl; div=MathAbs(zdh+zdl); if(div==0.00) temp=0; else temp=100*(MathAbs(zdhl)/div); if (zdh>zdl) fs=1; if (zdh<zdl) fs=2; if (fs==2) temp=-temp; zdx=zdxp+(temp-zdxp)*ki; ADX[i]=zdx; if (ADX[i]>ADX[i+1]) fss=1; if (ADX[i]<ADX[i+1]) {if (fss==1) ADXL[i+1]=ADX[i+1]; fss=2;} if (fss==2) ADXL[i]=ADX[i]; else ADXL[i]=0.0; levh[i]=Level; levl[i]=-Level; } return(0); } //******************************************************************

質問者が選んだベストアンサー

  • ベストアンサー
  • fhat6014
  • ベストアンサー率94% (34/36)
回答No.2

アラートが一本遅く見えるのは、MT4の表示上の仕様によるものです。 ラインの色の変化を表示する場合は、まず色の違う2本のラインを用意し、ある条件では色Aのラインに値を入れ、別の条件の時には色Bのラインにに値を入れて、この2本のラインを重ねて表示する事で色が変わったように表現します。 ただし、ラインは同じラインの隣り合う2つの点に値が入っていないと表示されないため、条件ごとに値を入れただけでは色の切り替わるポイントでラインが切れたように表示されてしまいます。 この切れ目を埋めるため、、色の切り替わるポイントでは切り替わる色のラインの足一本分前の位置ににライン表示用の値を代入するのが一般的です。 ですから、内部処理上の色の切り替わっているポイントは画面上の色が変わっている足の一本後の位置です。 とはいえ、調べたところ先の回答のものではどうやら不具合がありそうです。 これも正しく動くかどうかはわかりませんが、こちらを試してみてください。 http://ux.getuploader.com/mt4uploader/download/10/ADXm_Alert.zip

MT4Beginner
質問者

お礼

回答ありがとうございます。 早速、1時間平均足で試してみました。 貴殿の言われる通り、MT4の表示上の仕様なのか、ラインの色が変化と同時に、平均足の色も変化したのですが、平均足が2個目でAlertが鳴り、15分足の時と同じになります。 貴殿から教えていただいた、プログラムと同じだと思います。 やはりラインの変化と平均足の変化が一致しても、Alertは、平均足2個目で鳴るというのは、仕方ないようです。 ラインの色が、変化したのと同時にAlert(Sound)が鳴るとベストなのですが・・・、仕方ないようです。 ありがとうございます。

その他の回答 (1)

  • fhat6014
  • ベストアンサー率94% (34/36)
回答No.1

色転換は何かとややこしいので、動作保障はできませんが。 パラメーターに以下を追加 extern bool PopUpAlert=false; extern bool SoundAlert_Once = false; extern bool SoundAlert = false; プログラムの最後「return(0)」の上に以下を追加 static datetime lastBarTime = 0; bool newBar = false; if( lastBarTime != Time[0] ){ newBar = true; lastBarTime = Time[0]; } if( ADX[1] > ADX[2] && ADXL[2] < ADXL[3] && ADXL[2] != 0 ){ if( newBar && PopUpAlert ){ Alert("ADXm TrendChange UP "+Symbol()); } if( ( newBar && SoundAlert_Once ) || SoundAlert ){ PlaySound("alert"); } } if( ADXL[1] < ADXL[2] && ADX[2] > ADX[3] && ADXL[1] != 0 ){ if( newBar && PopUpAlert ){ Alert("ADXm TrendChange Down "+Symbol()); } if( ( newBar && SoundAlert_Once ) || SoundAlert ){ PlaySound("alert"); } }

MT4Beginner
質問者

お礼

ありがとうございます。 平均足1分で試してみました。ラインの色の変化に合わせて、平均足の色も変わったのですが、AlertもSoundも平均足の色が変化して2個目あたりで鳴ります。 教えていただいたプログラムは、基本はラインの色の変化でくまれているのでしょうか?ラインの右肩上がり、下がり、水平の角度なのでしょうか?時間的なものも関係するのでしょうか?ど素人質問ですいませんが、ご教授ください。 また、このOkWAVEは、貴殿をベストアンサーに選んだ場合、貴殿へポイントがつくのでしょうか?システムをいまひとつ理解していないため、すいません。 いろいろなことを教えていただき、申し訳ないと思い・・・。

MT4Beginner
質問者

補足

15分平均足でも、ラインの変化と同時に平均足の色も変わったのですが、平均足2個目でAlertが鳴りました。

関連するQ&A

  • MT4 2本 の EMA とそのHistogram

    下の MT4プログラム、 MACD と Histogram を 普通の2本 の EMA と そのHistogram に変更したいのですが、変更する部分の関連箇所のプログラムを教えて下さい。宜しくお願いいたします。 //---- indicator settings #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Aqua #property indicator_color2 Red #property indicator_color3 Green #property indicator_color4 Red //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double HistogramBufferUp[]; double HistogramBufferDown[]; int flagval1 = 0; int flagval2 = 0; //---- variables //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings // IndicatorBuffers(3); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(0,ind_buffer1); SetIndexDrawBegin(0,SlowEMA); SetIndexStyle(1,DRAW_LINE,STYLE_DOT); SetIndexBuffer(1,ind_buffer2); SetIndexDrawBegin(1,SignalSMA); SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID); SetIndexBuffer(2,HistogramBufferUp); SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID); SetIndexBuffer(3,HistogramBufferDown); // SetIndexDrawBegin(2,SlowEMA + SignalSMA); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")"); SetIndexLabel(0,"MACD"); SetIndexLabel(1,"Signal"); SetIndexLabel(2,"Histogram"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit; double temp; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd counted in the 1-st buffer for(int i=0; i<limit; i++) ind_buffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); //---- signal line counted in the 2-nd buffer for(i=0; i<limit; i++) ind_buffer2[i]=iMAOnArray(ind_buffer1,Bars,SignalSMA,0,MODE_SMA,i); // ind_buffer2[i] = alpha*ind_buffer1[i] + alpha_1*ind_buffer2[i+1]; for(i=0; i<limit; i++) { HistogramBufferUp[i] = 0; HistogramBufferDown[i] = 0; temp = ind_buffer1[i] - ind_buffer2[i]; if (temp >= 0) HistogramBufferUp[i] = temp; else HistogramBufferDown[i] = temp; } //---- done return(0); }

  • MT4プログラム、MACD と Histogram

    下の MT4プログラム、 MACD と Histogram を 単に 2本 の EMA と そのHistogram に 変更したいのですが、変更関連箇所のプログラムを教えて下さい。宜しくお願いいたし ます。 //---- indicator settings #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Aqua #property indicator_color2 Red #property indicator_color3 Green #property indicator_color4 Red //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double HistogramBufferUp[]; double HistogramBufferDown[]; int flagval1 = 0; int flagval2 = 0; //---- variables //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings // IndicatorBuffers(3); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(0,ind_buffer1); SetIndexDrawBegin(0,SlowEMA); SetIndexStyle(1,DRAW_LINE,STYLE_DOT); SetIndexBuffer(1,ind_buffer2); SetIndexDrawBegin(1,SignalSMA); SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID); SetIndexBuffer(2,HistogramBufferUp); SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID); SetIndexBuffer(3,HistogramBufferDown); // SetIndexDrawBegin(2,SlowEMA + SignalSMA); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")"); SetIndexLabel(0,"MACD"); SetIndexLabel(1,"Signal"); SetIndexLabel(2,"Histogram"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit; double temp; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd counted in the 1-st buffer for(int i=0; i<limit; i++) ind_buffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA (NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); //---- signal line counted in the 2-nd buffer for(i=0; i<limit; i++) ind_buffer2[i]=iMAOnArray(ind_buffer1,Bars,SignalSMA,0,MODE_SMA,i); // ind_buffer2[i] = alpha*ind_buffer1[i] + alpha_1*ind_buffer2[i+1]; for(i=0; i<limit; i++) { HistogramBufferUp[i] = 0; HistogramBufferDown[i] = 0; temp = ind_buffer1[i] - ind_buffer2[i]; if (temp >= 0) HistogramBufferUp[i] = temp; else HistogramBufferDown[i] = temp; } //---- done return(0); }

  • MT4 MQL 自作インジの問題点がわからない…

    自作インジをiいくつか作って、そのうちいくつかに動かしているとたまにバグ?が出るモノがあるのですがどうしてそうなるのか問題点がわからないです。 MT4 MQL 上級者の方ならわかるかとおもうのですが… 理由と修正点を教えてください。 以下MQL 例 #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 DodgerBlue #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_level1 30 #property indicator_level2 70 //指標バッファ double BufRSI[]; double TRDBuf[]; double haBuf[]; double haBuf2[]; //パラメーター extern int RSI_Period = 14; extern int up = 85; extern int down = 15; extern int haup = 70; extern int hadown = 30; //+------------------------------------------------------------------+ //| 初期化関数 | //+------------------------------------------------------------------+ int init() { //指標バッファの割り当て IndicatorBuffers(4); SetIndexBuffer(1,BufRSI); SetIndexBuffer(0,TRDBuf); SetIndexBuffer(2,haBuf); SetIndexBuffer(3,haBuf2); return(0); } //+------------------------------------------------------------------+ //| 指標処理関数 | //+------------------------------------------------------------------+ int start() { int limit = Bars-IndicatorCounted(); if(limit == Bars) limit -= RSI_Period-1; for(int i=limit-1; i>=0; i--) { BufRSI[i]=iRSI(NULL,0,RSI_Period,PRICE_CLOSE,i); } if(limit == Bars) limit -= RSI_Period-1; for(i=limit-1; i>=0; i--) { if (BufRSI[i+1]<haup && BufRSI[i+1]>hadown) { if(BufRSI[i]>haup) haBuf[i]=Close[i]; if(BufRSI[i]<hadown) haBuf2[i]=Close[i]; if(haBuf[i]<haBuf2[i]) int han=up; else han=down;      TRDBuf[i] = han ; } else TRDBuf[i] = down; } return(0); } これはRSI(14)が70未満から70より上になったときに haBuf[i] に終値をいれておき RSI(14)が30より上から30未満になったときに haBuf2[i] に終値をいれて haBuf[i]<haBuf2[i] だったら TRDBuf[i] を up (= 85) 違ったら down (= 15)と表示させるものです。 動かしているとたまに TRDBuf[i] が up (= 85) になるのですがプロパティーを開いて 何も変更せずにOKを押したら up (= 85) になっていたところが down (=15) になり何もなかったことになります。 (もしくは、up (= 85)がでてからまったく同じ条件のインジをいれたら新しく入れたほうは up (= 85)になっていない。) しかもこのバグ?が起こるときと起こらないときがあります。 この問題の原因がまったくわからないのですが知識のある方ご教授お願いします。

  • MT4 MACD

    下記、MACDのプログラムですが、MACDラインとSignalラインがクロスした際、(1)-(3)の条件を満たす、プログラム変更を、どなたか、詳しい方教えてください。 (1)Alertを鳴らす (2)Soundを1度鳴らす (3)Soundを鳴らし続ける #property copyright "Copyright ゥ 2005, David W. Thomas" #property link "mailto:davidwt@usa.net" #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Green #property indicator_color4 DeepPink #property indicator_width4 2 #property indicator_color5 Aqua #property indicator_width5 2 //---- input parameters extern int FastMAPeriod=12; extern int SlowMAPeriod=26; extern int SignalMAPeriod=9; extern bool ShowSignal = false; extern double SignalDiff = 0.000175; //---- buffers double MACDLineBuffer[]; double SignalLineBuffer[]; double HistogramBuffer[]; double AlertUpBuffer[]; double AlertDownBuffer[]; //---- variables double alpha = 0; double alpha_1 = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,MACDLineBuffer); SetIndexDrawBegin(0,SlowMAPeriod); SetIndexStyle(1,DRAW_LINE/*,STYLE_DOT*/); SetIndexBuffer(1,SignalLineBuffer); SetIndexDrawBegin(1,SlowMAPeriod+SignalMAPeriod); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(2,HistogramBuffer); SetIndexDrawBegin(2,SlowMAPeriod+SignalMAPeriod); SetIndexBuffer(3,AlertDownBuffer); SetIndexDrawBegin(3,SlowMAPeriod+SignalMAPeriod); SetIndexBuffer(4,AlertUpBuffer); SetIndexDrawBegin(4,SlowMAPeriod+SignalMAPeriod); if(ShowSignal){ SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,119); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,119); }else{ SetIndexStyle(3,DRAW_NONE); SetIndexStyle(4,DRAW_NONE); } //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD-VT("+FastMAPeriod+","+SlowMAPeriod+","+SignalMAPeriod+")"); SetIndexLabel(0,"MACD"); SetIndexLabel(1,"Signal"); SetIndexLabel(2,"Hist"); SetIndexLabel(3,NULL); SetIndexLabel(4,NULL); //---- alpha = 2.0 / (SignalMAPeriod + 1.0); alpha_1 = 1.0 - alpha; //---- if(StringFind(Symbol(),"JPY")!=-1) SignalDiff=SignalDiff*100; Print("SignalDiff = ",SignalDiff); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars = IndicatorCounted(); //---- check for possible errors if (counted_bars<0) return(-1); //---- last counted bar will be recounted if (counted_bars>0) counted_bars--; limit = Bars - counted_bars; for(int i=limit; i>=0; i--) { MACDLineBuffer[i] = iMA(NULL,0,FastMAPeriod,0,MODE_EMA,PRICE_CLOSE,i) - iMA(NULL,0,SlowMAPeriod,0,MODE_EMA,PRICE_CLOSE,i); SignalLineBuffer[i] = alpha*MACDLineBuffer[i] + alpha_1*SignalLineBuffer[i+1]; HistogramBuffer[i] = MACDLineBuffer[i] - SignalLineBuffer[i]; if(MACDLineBuffer[i] >MACDLineBuffer[i+1]+SignalDiff ){ AlertUpBuffer[i]=MACDLineBuffer[i]; }else{ AlertUpBuffer[i]=EMPTY_VALUE; } if(MACDLineBuffer[i] <MACDLineBuffer[i+1]-SignalDiff){ AlertDownBuffer[i]=MACDLineBuffer[i]; }else{ AlertDownBuffer[i]=EMPTY_VALUE; } } //---- return(0); } //+------------------------------------------------------------------+

  • MT4 MACD

    MACDとSIGNALがクロスした際の、(1)-(3)の条件を満たす、プログラム変更を教えてください。 (1)Alertを鳴らす(2)Soundを1度鳴らす(3)Soundを鳴らし続ける #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 DeepSkyBlue #property indicator_color2 DeepPink #property indicator_color3 Green #property indicator_color4 DeepPink #property indicator_width4 2 #property indicator_color5 Aqua #property indicator_width5 2 //---- input parameters extern int FastMAPeriod=12; extern int SlowMAPeriod=26; extern string _ma = "0:SMA 1:EMA 2:SMMA 3:LWMA"; extern int MAMethod = MODE_EMA; extern int SignalMAPeriod=9; extern int SignalMAMethod = MODE_EMA; extern bool ShowSignal = false; extern double SignalDiff = 0.000175; //---- buffers double MACDLineBuffer[]; double SignalLineBuffer[]; double HistogramBuffer[]; double AlertUpBuffer[]; double AlertDownBuffer[]; //---- variables double alpha = 0; double alpha_1 = 0; //| Custom indicator initialization function | int init() { IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,MACDLineBuffer); SetIndexDrawBegin(0,SlowMAPeriod); SetIndexStyle(1,DRAW_LINE/*,STYLE_DOT*/); SetIndexBuffer(1,SignalLineBuffer); SetIndexDrawBegin(1,SlowMAPeriod+SignalMAPeriod); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(2,HistogramBuffer); SetIndexDrawBegin(2,SlowMAPeriod+SignalMAPeriod); SetIndexBuffer(3,AlertDownBuffer); SetIndexDrawBegin(3,SlowMAPeriod+SignalMAPeriod); SetIndexBuffer(4,AlertUpBuffer); SetIndexDrawBegin(4,SlowMAPeriod+SignalMAPeriod); if(ShowSignal){ SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,119); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,119); }else{ SetIndexStyle(3,DRAW_NONE); SetIndexStyle(4,DRAW_NONE); } //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD+("+FastMAPeriod+","+SlowMAPeriod+","+SignalMAPeriod+")"); SetIndexLabel(0,"MACD"); SetIndexLabel(1,"Signal"); SetIndexLabel(2,"Hist"); SetIndexLabel(3,NULL); SetIndexLabel(4,NULL); //---- //alpha = 2.0 / (SignalMAPeriod + 1.0); //alpha_1 = 1.0 - alpha; //---- if(StringFind(Symbol(),"JPY")!=-1) SignalDiff=SignalDiff*100; Print("SignalDiff = ",SignalDiff); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit,i; int counted_bars = IndicatorCounted(); //---- check for possible errors if (counted_bars<0) return(-1); //---- last counted bar will be recounted if (counted_bars>0) counted_bars--; limit = Bars - counted_bars; for(i=limit; i>=0; i--) { MACDLineBuffer[i] = iMA(NULL,0,FastMAPeriod,0,MAMethod,PRICE_CLOSE,i) - iMA(NULL,0,SlowMAPeriod,0,MAMethod,PRICE_CLOSE,i); } for(i=limit; i>=0; i--) { //SignalLineBuffer[i] = alpha*MACDLineBuffer[i] + alpha_1*SignalLineBuffer[i+1]; SignalLineBuffer[i] = iMAOnArray(MACDLineBuffer,0,SignalMAPeriod,0,SignalMAMethod,i); HistogramBuffer[i] = MACDLineBuffer[i] - SignalLineBuffer[i]; if(MACDLineBuffer[i] >MACDLineBuffer[i+1]+SignalDiff ){ AlertUpBuffer[i]=MACDLineBuffer[i]; }else{ AlertUpBuffer[i]=EMPTY_VALUE; } if(MACDLineBuffer[i] <MACDLineBuffer[i+1]-SignalDiff){ AlertDownBuffer[i]=MACDLineBuffer[i]; }else{ AlertDownBuffer[i]=EMPTY_VALUE; } } //---- return(0);

  • MT4 BBandWidthRatio(VT系)

    fhat6014様 この質問の前にADXのMTF化の質問をしているのですが、貴殿に以前紹介頂いた、BBandWidthRatioのVT系のインジケータもMTF化できるのでしょうか?現在、紹介頂いたサイトからインジケータが削除されているため、プログラムを記載させて頂きます。可能であれば、教えていただけないでしょうか。 #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Purple #property indicator_color2 Blue #property indicator_color3 Red #property indicator_style2 STYLE_DOT #property indicator_style3 STYLE_DOT #property indicator_minimum 0 //---- input parameters extern int BB_Period=18; extern double Deviation=2.0; extern int Bulgeper=150; extern int Squeezeper=150; double buf1[]; //double buf2[]; //double buf3[]; //double buf4[]; double bufBulgeper[]; double bufSqueezeper[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS)); SetIndexDrawBegin(0,BB_Period); SetIndexLabel(0,"BBandWidthRatio"); SetIndexBuffer(0, buf1); SetIndexDrawBegin(1,BB_Period); SetIndexLabel(1,"Bulgeper"); SetIndexBuffer(1, bufBulgeper); SetIndexDrawBegin(2,BB_Period); SetIndexLabel(2,"Squeezeper"); SetIndexBuffer(2, bufSqueezeper); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i, j; double ave, sko, sum; int counted_bars=IndicatorCounted(); double MA, Up, Dn; if(Bars<=BB_Period) return(0); if(BB_Period==0) return(0); int limit = Bars - counted_bars; for (i=limit-1; i>=0; i--) { // buf2[i] = iMA(NULL,0,BB_Period,0,MODE_SMA,PRICE_CLOSE,i); MA = iMA(NULL,0,BB_Period,0,MODE_SMA,PRICE_CLOSE,i); sum = 0; for (j=0; j<BB_Period; j++) sum+=Close[i+j]; ave = sum / BB_Period; sum = 0; for (j=0; j<BB_Period; j++) sum+=(Close[i+j]-ave)*(Close[i+j]-ave); sko = MathSqrt(sum / BB_Period); // buf4[i] = buf2[i]+(Deviation*sko); // buf3[i] = buf2[i]-(Deviation*sko); Up = MA+(Deviation*sko); Dn = MA-(Deviation*sko); // buf1[i] = 2*(Deviation*sko)/buf2[i]; if( MA != 0 ){ buf1[i] = 2*(Deviation*sko)/MA; bufBulgeper[i] = buf1[ArrayMaximum(buf1,Bulgeper,i)]; bufSqueezeper[i] = buf1[ArrayMinimum(buf1,Squeezeper,i)]; } } return(0); }

  • MT4 スローストキャスティクスについて

    下記MT4のスローストキャスティクスのプログラムなのですが、クロスした際にサウンドを鳴らすには、 どのようにプログラムを変えたら良いのでしょうか?どなたか詳しい方、ご教授願います。 詳しい方からすれば、なんてことないことなのですが、全くの初心者で困っています。 どなたか、どうぞよろしくお願いします。 #property copyright "Copyright ?2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 2 #property indicator_color1 LightSeaGreen #property indicator_color2 Red //---- input parameters extern int KPeriod=42; extern int DPeriod=3; extern int Slowing=3; //---- buffers double KBuffer[]; double DBuffer[]; double MainBuffer[]; double SignalBuffer[]; double HighesBuffer[]; double LowesBuffer[]; //---- int draw_begin1=0; int draw_begin2=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- 2 additional buffers are used for counting. IndicatorBuffers(6); SetIndexBuffer(2, HighesBuffer); SetIndexBuffer(3, LowesBuffer); SetIndexBuffer(4, MainBuffer); SetIndexBuffer(5, SignalBuffer); //---- indicator lines SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0, KBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1, DBuffer); //---- name for DataWindow and indicator subwindow label short_name="SlowKD("+KPeriod+","+DPeriod+","+Slowing+")"; IndicatorShortName(short_name); SetIndexLabel(4,short_name); SetIndexLabel(5,"Signal"); //---- draw_begin1=KPeriod+Slowing; draw_begin2=draw_begin1+DPeriod; SetIndexDrawBegin(0,draw_begin1); SetIndexDrawBegin(1,draw_begin2); //---- return(0); } //+------------------------------------------------------------------+ //| Stochastic oscillator | //+------------------------------------------------------------------+ int start() { int i,k; int counted_bars=IndicatorCounted(); double price; //---- if(Bars<=draw_begin2) return(0); //---- initial zero if(counted_bars<1) { for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0; for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0; } //---- minimums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double min=1000000; k=i+KPeriod-1; while(k>=i) { price=Low[k]; if(min>price) min=price; k--; } LowesBuffer[i]=min; i--; } //---- maximums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double max=-1000000; k=i+KPeriod-1; while(k>=i) { price=High[k]; if(max<price) max=price; k--; } HighesBuffer[i]=max; i--; } //---- %K line i=Bars-draw_begin1; if(counted_bars>draw_begin1) i=Bars-counted_bars-1; while(i>=0) { double sumlow=0.0; double sumhigh=0.0; for(k=(i+Slowing-1);k>=i;k--) { sumlow+=Close[k]-LowesBuffer[k]; sumhigh+=HighesBuffer[k]-LowesBuffer[k]; } if(sumhigh==0.0) MainBuffer[i]=100.0; else MainBuffer[i]=sumlow/sumhigh*100; i--; } //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; //---- signal line is simple movimg average for(i=0; i<limit; i++) KBuffer[i]=iMAOnArray(MainBuffer,Bars,Slowing,0,MODE_SMA,i); for(i=0; i<limit; i++) DBuffer[i]=iMAOnArray(KBuffer,Bars,DPeriod,0,MODE_SMA,i); //---- return(0); } //+------------------------------------------------------------------+

  • MT4 BollingerBands

    下記のように±σ1をDOT表示にプログラムしているのですが、DOTではなくSOLIDになります。何がいけないか、プログラムに詳しい方、教えてください。 #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Black #property indicator_width1 2 #property indicator_color2 Teal #property indicator_width2 0 #property indicator_color3 Teal #property indicator_width3 0 //---- indicator parameters extern int BandsPeriod=20; extern int BandsShift=0; extern double BandsDeviations=1.0; //---- buffers double MovingBuffer[]; double UpperBuffer[]; double LowerBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(0,MovingBuffer); SetIndexStyle(1,DRAW_LINE,STYLE_DOT); SetIndexBuffer(1,UpperBuffer); SetIndexStyle(2,DRAW_LINE,STYLE_DOT); SetIndexBuffer(2,LowerBuffer);

  • MT4 スローストキャスティクス(前回同様)

    fhat6014様 前回と同様に(1)Alertを鳴らす(2)Soundを1度鳴らす(3)Soundを鳴らし続けるとい設定を一まとめで設定できるのでしょうか。教えてください。 #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 2 #property indicator_color1 Lime #property indicator_color2 Red //---- input parameters extern int KPeriod=42; extern int DPeriod=3; extern int Slowing=3; //---- buffers double KBuffer[]; double DBuffer[]; double MainBuffer[]; double SignalBuffer[]; double HighesBuffer[]; double LowesBuffer[]; //---- int draw_begin1=0; int draw_begin2=0; //| Custom indicator initialization function | int init() { string short_name; //---- 2 additional buffers are used for counting. IndicatorBuffers(6); SetIndexBuffer(2, HighesBuffer); SetIndexBuffer(3, LowesBuffer); SetIndexBuffer(4, MainBuffer); SetIndexBuffer(5, SignalBuffer); //---- indicator lines SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0, KBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1, DBuffer); //---- name for DataWindow and indicator subwindow label short_name="SlowKD("+KPeriod+","+DPeriod+","+Slowing+")"; IndicatorShortName(short_name); SetIndexLabel(4,short_name); SetIndexLabel(5,"Signal"); //---- draw_begin1=KPeriod+Slowing; draw_begin2=draw_begin1+DPeriod; SetIndexDrawBegin(0,draw_begin1); SetIndexDrawBegin(1,draw_begin2); //---- return(0); } //| Stochastic oscillator | int start() { int i,k; int counted_bars=IndicatorCounted(); double price; //---- if(Bars<=draw_begin2) return(0); //---- initial zero if(counted_bars<1) { for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0; for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0; } //---- minimums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double min=1000000; k=i+KPeriod-1; while(k>=i) { price=Low[k]; if(min>price) min=price; k--; } LowesBuffer[i]=min; i--; } //---- maximums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double max=-1000000; k=i+KPeriod-1; while(k>=i) { price=High[k]; if(max<price) max=price; k--; } HighesBuffer[i]=max; i--; } //---- %K line i=Bars-draw_begin1; if(counted_bars>draw_begin1) i=Bars-counted_bars-1; while(i>=0) { double sumlow=0.0; double sumhigh=0.0; for(k=(i+Slowing-1);k>=i;k--) { sumlow+=Close[k]-LowesBuffer[k]; sumhigh+=HighesBuffer[k]-LowesBuffer[k]; } if(sumhigh==0.0) MainBuffer[i]=100.0; else MainBuffer[i]=sumlow/sumhigh*100; i--; } //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; //---- signal line is simple movimg average for(i=0; i<limit; i++) KBuffer[i]=iMAOnArray(MainBuffer,Bars,Slowing,0,MODE_SMA,i); for(i=0; i<limit; i++) DBuffer[i]=iMAOnArray(KBuffer,Bars,DPeriod,0,MODE_SMA,i); //---- return(0); }

  • MT4 ストキャスティクス

    下記、MT4ストキャスティクスのプログラムなのですが、下記(1)(2)(3)の条件を満たすには、どのようにプログラムを変更したらよいのでしょうか。 詳しい方、教えてください。 (1)Alertを出すには。 (2)Soundを1度だけ鳴らすには (3)Soundを鳴らし続けるには 先日、プログラムに詳しい方からスローの方でご教授いただいたのですが、その方への連絡の取り方がわからないため、どなたかご教授ください。お願いします。 #property copyright "Copyright ゥ 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 2 #property indicator_color1 Lime #property indicator_color2 Red //---- input parameters extern int KPeriod=42; extern int DPeriod=3; extern int Slowing=3; //---- buffers double MainBuffer[]; double SignalBuffer[]; double HighesBuffer[]; double LowesBuffer[]; //---- int draw_begin1=0; int draw_begin2=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- 2 additional buffers are used for counting. IndicatorBuffers(4); SetIndexBuffer(2, HighesBuffer); SetIndexBuffer(3, LowesBuffer); //---- indicator lines SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0, MainBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1, SignalBuffer); //---- name for DataWindow and indicator subwindow label short_name="Sto("+KPeriod+","+DPeriod+","+Slowing+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); SetIndexLabel(1,"Signal"); //---- draw_begin1=KPeriod+Slowing; draw_begin2=draw_begin1+DPeriod; SetIndexDrawBegin(0,draw_begin1); SetIndexDrawBegin(1,draw_begin2); //---- return(0); } //+------------------------------------------------------------------+ //| Stochastic oscillator | //+------------------------------------------------------------------+ int start() { int i,k; int counted_bars=IndicatorCounted(); double price; //---- if(Bars<=draw_begin2) return(0); //---- initial zero if(counted_bars<1) { for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0; for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0; } //---- minimums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double min=1000000; k=i+KPeriod-1; while(k>=i) { price=Low[k]; if(min>price) min=price; k--; } LowesBuffer[i]=min; i--; } //---- maximums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double max=-1000000; k=i+KPeriod-1; while(k>=i) { price=High[k]; if(max<price) max=price; k--; } HighesBuffer[i]=max; i--; } //---- %K line i=Bars-draw_begin1; if(counted_bars>draw_begin1) i=Bars-counted_bars-1; while(i>=0) { double sumlow=0.0; double sumhigh=0.0; for(k=(i+Slowing-1);k>=i;k--) { sumlow+=Close[k]-LowesBuffer[k]; sumhigh+=HighesBuffer[k]-LowesBuffer[k]; } if(sumhigh==0.0) MainBuffer[i]=100.0; else MainBuffer[i]=sumlow/sumhigh*100; i--; } //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; //---- signal line is simple movimg average for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MainBuffer,Bars,DPeriod,0,MODE_SMA,i); //---- return(0); } //+------------------------------------------------------------------+