MT4 MACDプログラム変更方法

このQ&Aのポイント
  • MT4 MACDのプログラム変更方法を教えてください。
  • MACDとSIGNALがクロスした際の条件を満たすプログラム変更方法を教えてください。
  • MACDとSIGNALがクロスした際にAlertを鳴らすプログラム変更方法を教えてください。
回答を見る
  • ベストアンサー

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);

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

  • ベストアンサー
  • 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( HistogramBuffer[1] > 0 && HistogramBuffer[2] < 0 ){ if( newBar && PopUpAlert ){ Alert("MACD Cross UP "+Symbol()); } if( ( newBar && SoundAlert_Once ) || SoundAlert ){ PlaySound("alert"); } } if( HistogramBuffer[1] < 0 && HistogramBuffer[2] > 0 ){ if( newBar && PopUpAlert ){ Alert("MACD Cross Down "+Symbol()); } if( ( newBar && SoundAlert_Once ) || SoundAlert ){ PlaySound("alert"); } }

MT4Beginner
質問者

お礼

ありがとうございます。

関連するQ&A

  • 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 と 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 スローストキャスティクス(前回同様)

    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 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 スローストキャスティクスについて

    下記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 ストキャスティクス(前回同様)

    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 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); }

  • 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); } //+------------------------------------------------------------------+

  • MACD と Histogram のプログラム

    下のプログラム、 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); } //+------------------------------------------------------------------+

  • MACD

    下記、MACDを表示するとMACDラインは、EMA表示だと思うのですが、SignalラインがSMAで表示されているような気がします。プログラム上、EMA、SMAの表記がないので、どこを変更すれば、SignalラインがEMAになるのかわかるかた教えてください。 #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DeepSkyBlue #property indicator_width1 2 #property indicator_color2 Red #property indicator_width2 2 #property indicator_level1 0 #property indicator_levelcolor White //---- input parameters extern int fast_Period = 12; extern int slow_Period = 26; extern int signal_Period = 9; extern string AlertSound = "alert.wav"; //---- buffers double Buffer1[]; double Buffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,1,2); SetIndexBuffer(0,Buffer1); SetIndexLabel(0,"Main"); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,Buffer2); SetIndexLabel(1,"Signal"); //---- return(0);} //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() {int counted_bars = IndicatorCounted(); int limit = Bars - counted_bars; for(int i=0; i < limit; i++) {Buffer1[i] = iMACD(NULL, 0, fast_Period, slow_Period,signal_Period, PRICE_CLOSE,MODE_MAIN , i); Buffer2[i] = iMACD(NULL, 0, fast_Period, slow_Period,signal_Period, PRICE_CLOSE,MODE_SIGNAL , i); } if(Buffer1[1] < Buffer2[1] && Buffer1[0] > Buffer2[0]) { PlaySound(AlertSound); ObjectDelete("BuySignal"); ObjectCreate("BuySignal",OBJ_ARROW,0 ,Time[0] ,Low[0]-10*Point); ObjectSet("BuySignal",OBJPROP_ARROWCODE, 217); ObjectSet("BuySignal",OBJPROP_COLOR, Blue); } else if(Buffer1[1] > Buffer2[1] && Buffer1[0] < Buffer2[0]) {PlaySound(AlertSound); ObjectDelete("SellSignal"); ObjectCreate("SellSignal",OBJ_ARROW,0 ,Time[0] ,High[0]+10*Point); ObjectSet("SellSignal",OBJPROP_ARROWCODE, 218); ObjectSet("SellSignal",OBJPROP_COLOR, Red); } //Comment ("MAIN: ",Buffer1[0]," / SIGNAL: ",Buffer2[0]); return(0);} //+------------------------------------------------------------------+

  • MT4 MACD

    下記、MACDのプログラムですが、MACDラインとSignalラインがクロスした際、(1)-(3)の条件を満たす、プログラム変更を、どなたか、詳しい方教えてください。 (1)Alertを鳴らす (2)Soundを1度鳴らす (3)Soundを鳴らし続ける #property copyright "Copyright(C) 2005 S.B.T. All Rights Reserved." #property link "http://sufx.core.t3-ism.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 MediumSeaGreen #property indicator_color2 DarkOrange #property indicator_color3 Crimson #property indicator_color4 SteelBlue //---- indicator parameters extern int FastMA=12; extern int SlowMA=26; extern int MA_Method=1; extern int SignalMA=9; extern int SignalMA_Method=1; extern int Apply=0; extern int Timeframe=0; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double ind_buffer3[]; double ind_buffer4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name1,short_name2,short_name3; //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID); SetIndexDrawBegin(1,SignalMA); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); //---- indicator buffers mapping if(!SetIndexBuffer(0,ind_buffer1) && !SetIndexBuffer(1,ind_buffer2) && !SetIndexBuffer(2,ind_buffer3) && !SetIndexBuffer(3,ind_buffer4)) Print("cannot set indicator buffers!"); //---- name for DataWindow and indicator subwindow label switch(MA_Method) { case 1 : short_name1="EMA("; break; case 2 : short_name1="SMMA("; break; case 3 : short_name1="LWMA("; break; default : MA_Method=0; short_name1="SMA("; } switch(SignalMA_Method) { case 1 : short_name2="EMA("; break; case 2 : short_name2="SMMA("; break; case 3 : short_name2="LWMA("; break; default : SignalMA_Method=0; short_name2="SMA("; } switch(Apply) { case 1 : short_name3="Apply to Open price"; break; case 2 : short_name3="Apply to High price"; break; case 3 : short_name3="Apply to Low price"; break; case 4 : short_name3="Apply to Median price, (high+low)/2"; break; case 5 : short_name3="Apply to Typical price, (high+low+close)/3"; break; case 6 : short_name3="Apply to Weighted close price, (high+low+close+close)/4"; break; default : Apply=0; short_name3="Apply to Close price"; } IndicatorShortName("MACD("+short_name1+FastMA+"),"+short_name1+SlowMA+"),"+short_name2+SignalMA+")) "+short_name3); SetIndexLabel(0,"Oscillator"); SetIndexLabel(1,"Oscillator"); SetIndexLabel(2,"Signal"); SetIndexLabel(3,"MACD"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ 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; //---- macd counted in the 1-st buffer for(int i=0; i<limit; i++) { ind_buffer4[i]=iMA(NULL,Timeframe,FastMA,0,MA_Method,Apply,i)-iMA(NULL,Timeframe,SlowMA,0,MA_Method,Apply,i); } //---- signal line counted in the 2-nd buffer for(i=0; i<limit; i++) { ind_buffer3[i]=iMAOnArray(ind_buffer4,Bars,SignalMA,0,SignalMA_Method,i); } //---- done //---- signal line counted in the 3-rd buffer for(i=0; i<limit; i++) { ind_buffer1[i]=ind_buffer4[i]-ind_buffer3[i]; } for(i=0; i<limit-1; i++) { if (ind_buffer1[i]<ind_buffer1[i+1]) ind_buffer2[i]=ind_buffer1[i]; else ind_buffer2[i]=0; } //---- done return(0); }