コーディングのヘルプ - ページ 329

 

これを日足チャートに貼り付けてみて、そのインディケータをベースにしたEAができるかどうか教えてください。

 
mj023:
日足チャートに貼り付けてみて、そのインジケータをベースにしたEAができるかどうか教えてください。

なるほど

これは、シグナルを持つ可能性のないラベルベースのインジケータです(前値と現在値を知ることができる)。意味:シグナルが使用できず、EAがシグナルを一意に識別できない。申し訳ありませんが、冗長性のないEAの可能性はありません。

 

こんにちは。

このコードのどこが問題なのでしょうか?私は、ソースのインディケータからicustom関数を 使用してmtfインディケータを取得しようとしています。いつ間違っているのかがわかりません。どこに間違いがあるのか教えてください。

私はそれがすでに新しいビルドのためにコード化されているこの指標を知っているが、そのmtfバージョンは、非標準の時間枠に適していないと私はそれらを必要としています。

ソースのインジケータ。

//+------------------------------------------------------------------+

//| Macd_with_EMA_BDv09_12_22.mq4 |

//| Jeff |

//| wolfboy@att.net |

//+------------------------------------------------------------------+

#property copyright "Jeff"

#property link "wolfboy@att.net"

#property indicator_separate_window

#property indicator_buffers 7

#property indicator_color1 LimeGreen

#property indicator_color2 LimeGreen

#property indicator_color3 Plum

#property indicator_color4 Plum

#property indicator_color5 CLR_NONE

#property indicator_color6 Black

#property indicator_color7 CLR_NONE

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

#property indicator_width4 2

#property indicator_width5 1

#property indicator_width6 1

#property indicator_width7 2

#property indicator_level1 0.0

#property indicator_levelcolor DimGray

#property indicator_levelstyle 0

//---- indicator parameters

extern int Nbars = 500;

extern int FastEMA = 10;

extern int SlowEMA = 20;

extern int SignalEMA = 1;

extern int MAofSignalPer = 7;

//---- indicator buffers

double green_buffer[];

double DarkGreen_buffer[];

double red_buffer[];

double Maroon_buffer[];

double MacdBuffer[];

double SignalBuffer[];

double MAofSignalBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

IndicatorBuffers(7);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(4,DRAW_NONE);

SetIndexStyle(5,DRAW_LINE,STYLE_SOLID);

SetIndexStyle(6,DRAW_LINE,STYLE_DOT);

SetIndexDrawBegin(1,SignalEMA);

IndicatorDigits(Digits+1);

//---- indicator buffers mapping

SetIndexBuffer(0,green_buffer);

SetIndexBuffer(1,DarkGreen_buffer);

SetIndexBuffer(2,red_buffer);

SetIndexBuffer(3,Maroon_buffer);

SetIndexBuffer(4,MacdBuffer);

SetIndexBuffer(5,SignalBuffer);

SetIndexBuffer(6,MAofSignalBuffer);

//---- name for DataWindow and indicator subwindow label

IndicatorShortName("MACD in color ("+FastEMA+", "+SlowEMA+", "+SignalEMA+", "+MAofSignalPer+")");

SetIndexLabel(4,"MACD in color");

SetIndexLabel(5,"Signal");

SetIndexLabel(6,"MAofSignal");

//---- initialization done

return(0);

}

//+------------------------------------------------------------------+

//| Moving Averages Convergence/Divergence |

//+------------------------------------------------------------------+

int start()

{

int limit, i;

double MACD;

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

limit=Nbars-counted_bars;

//---- macd

for(i=0; i<limit; i++)

MacdBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-

iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

//---- signal line

for(i=0; i<limit; i++)

SignalBuffer=iMAOnArray(MacdBuffer,Bars,SignalEMA,0,MODE_EMA,i);

//---- MA of signal

for(i=0; i<limit; i++)

MAofSignalBuffer=iMAOnArray(SignalBuffer,Bars,MAofSignalPer,0,MODE_EMA,i);

for (i = Bars - Max (counted_bars-1, 1); i>=0; i--)

{

MACD=MacdBuffer;

if(MACD>0)

{

if (MACD>MacdBuffer)

{

green_buffer = MACD;

DarkGreen_buffer = 0;

}

else

{

green_buffer = 0;

DarkGreen_buffer = MACD;

}

}

else

{

if (MACD<MacdBuffer)

{

red_buffer = 0;

Maroon_buffer = MACD;

}

else

{

red_buffer = MACD;

Maroon_buffer = 0;

}

}

}

//---- done

return(0);

}

//+------------------------------------------------------------------+

int Max (int val1, int val2) {

if (val1 > val2) return(val1);

return(val2);

}

[/CODE]

and this is mine:

[CODE]//+------------------------------------------------------------------+

//| Macd_with_EMA_BDv09_12_22.mq4 |

//| Jeff |

//| wolfboy@att.net |

//+------------------------------------------------------------------+

#property copyright "Jeff"

#property link "wolfboy@att.net"

#property indicator_separate_window

#property indicator_buffers 7

#property indicator_color1 LimeGreen

#property indicator_color2 LimeGreen

#property indicator_color3 Plum

#property indicator_color4 Plum

#property indicator_color5 CLR_NONE

#property indicator_color6 Black

#property indicator_color7 CLR_NONE

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

#property indicator_width4 2

#property indicator_width5 1

#property indicator_width6 1

#property indicator_width7 2

#property indicator_level1 0.0

#property indicator_levelcolor DimGray

#property indicator_levelstyle 0

//---- indicator parameters

extern int TimeFrame = 0;

extern int Nbars = 500;

extern int FastEMA = 10;

extern int SlowEMA = 20;

extern int SignalEMA = 1;

extern int MAofSignalPer = 7;

//---- indicator buffers

double green_buffer[];

double DarkGreen_buffer[];

double red_buffer[];

double Maroon_buffer[];

double MacdBuffer[];

double SignalBuffer[];

double MAofSignalBuffer[];

string IndicatorFileName;

string short_name;

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

//

//

//

//

//

int init()

{

//---- indicator buffers mapping

SetIndexBuffer(0,green_buffer);

SetIndexBuffer(1,DarkGreen_buffer);

SetIndexBuffer(2,red_buffer);

SetIndexBuffer(3,Maroon_buffer);

SetIndexBuffer(4,MacdBuffer);

SetIndexBuffer(5,SignalBuffer);

SetIndexBuffer(6,MAofSignalBuffer);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(4,DRAW_NONE);

SetIndexStyle(5,DRAW_LINE,STYLE_SOLID);

SetIndexStyle(6,DRAW_LINE,STYLE_DOT);

SetIndexDrawBegin(1,SignalEMA);

IndicatorDigits(Digits+1);

switch(TimeFrame)

{

case 1: string TimeFrameStr = "M1" ; break;

case 5 : TimeFrameStr = "M5" ; break;

case 15 : TimeFrameStr = "M15"; break;

case 30 : TimeFrameStr = "M30"; break;

case 60 : TimeFrameStr = "H1" ; break;

case 240 : TimeFrameStr = "H4" ; break;

case 1440 : TimeFrameStr = "D1" ; break;

case 10080 : TimeFrameStr = "W1" ; break;

case 43200 : TimeFrameStr = "MN1"; break;

default : TimeFrameStr = "TF0";

}

TimeFrame = MathMax(TimeFrame,Period());

IndicatorFileName = WindowExpertName();

short_name = ("MACD in color MTF ("+TimeFrameStr+")") ;

IndicatorShortName(short_name);

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int counted_bars = IndicatorCounted();

int limit, i;

if(counted_bars < 0) return(-1);

if(counted_bars > 0) counted_bars--;

limit = Nbars - counted_bars;

if (TimeFrame != Period())

{

limit = MathMax(limit,TimeFrame/Period());

for(i = 0; i < limit; i++)

{

int y = iBarShift(NULL,TimeFrame,Time);

green_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,0,y);

DarkGreen_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,1,y);

red_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,2,y);

Maroon_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,3,y);

MacdBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,4,y);

SignalBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,5,y);

MAofSignalBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,6,y);

}

return(0);

}

}
 
thefxpros:
こんにちは。

このコードの何が問題なのでしょうか?私は、ソースのインディケータからicustom関数を使用してmtfインディケータを取得しようとしています。いつ間違っているのかがわかりません。どこに間違いがあるのか教えてください。

私はそれがすでに新しいビルドのためにコード化されているこの指標を知っているが、そのmtfバージョンは、非標準の時間枠に適していないと私はそれらを必要としています。

ソースのインジケーターです。

//+------------------------------------------------------------------+

//| Macd_with_EMA_BDv09_12_22.mq4 |

//| Jeff |

//| wolfboy@att.net |

//+------------------------------------------------------------------+

#property copyright "Jeff"

#property link "wolfboy@att.net"

#property indicator_separate_window

#property indicator_buffers 7

#property indicator_color1 LimeGreen

#property indicator_color2 LimeGreen

#property indicator_color3 Plum

#property indicator_color4 Plum

#property indicator_color5 CLR_NONE

#property indicator_color6 Black

#property indicator_color7 CLR_NONE

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

#property indicator_width4 2

#property indicator_width5 1

#property indicator_width6 1

#property indicator_width7 2

#property indicator_level1 0.0

#property indicator_levelcolor DimGray

#property indicator_levelstyle 0

//---- indicator parameters

extern int Nbars = 500;

extern int FastEMA = 10;

extern int SlowEMA = 20;

extern int SignalEMA = 1;

extern int MAofSignalPer = 7;

//---- indicator buffers

double green_buffer[];

double DarkGreen_buffer[];

double red_buffer[];

double Maroon_buffer[];

double MacdBuffer[];

double SignalBuffer[];

double MAofSignalBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

IndicatorBuffers(7);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(4,DRAW_NONE);

SetIndexStyle(5,DRAW_LINE,STYLE_SOLID);

SetIndexStyle(6,DRAW_LINE,STYLE_DOT);

SetIndexDrawBegin(1,SignalEMA);

IndicatorDigits(Digits+1);

//---- indicator buffers mapping

SetIndexBuffer(0,green_buffer);

SetIndexBuffer(1,DarkGreen_buffer);

SetIndexBuffer(2,red_buffer);

SetIndexBuffer(3,Maroon_buffer);

SetIndexBuffer(4,MacdBuffer);

SetIndexBuffer(5,SignalBuffer);

SetIndexBuffer(6,MAofSignalBuffer);

//---- name for DataWindow and indicator subwindow label

IndicatorShortName("MACD in color ("+FastEMA+", "+SlowEMA+", "+SignalEMA+", "+MAofSignalPer+")");

SetIndexLabel(4,"MACD in color");

SetIndexLabel(5,"Signal");

SetIndexLabel(6,"MAofSignal");

//---- initialization done

return(0);

}

//+------------------------------------------------------------------+

//| Moving Averages Convergence/Divergence |

//+------------------------------------------------------------------+

int start()

{

int limit, i;

double MACD;

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

limit=Nbars-counted_bars;

//---- macd

for(i=0; i<limit; i++)

MacdBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-

iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

//---- signal line

for(i=0; i<limit; i++)

SignalBuffer=iMAOnArray(MacdBuffer,Bars,SignalEMA,0,MODE_EMA,i);

//---- MA of signal

for(i=0; i<limit; i++)

MAofSignalBuffer=iMAOnArray(SignalBuffer,Bars,MAofSignalPer,0,MODE_EMA,i);

for (i = Bars - Max (counted_bars-1, 1); i>=0; i--)

{

MACD=MacdBuffer;

if(MACD>0)

{

if (MACD>MacdBuffer)

{

green_buffer = MACD;

DarkGreen_buffer = 0;

}

else

{

green_buffer = 0;

DarkGreen_buffer = MACD;

}

}

else

{

if (MACD<MacdBuffer)

{

red_buffer = 0;

Maroon_buffer = MACD;

}

else

{

red_buffer = MACD;

Maroon_buffer = 0;

}

}

}

//---- done

return(0);

}

//+------------------------------------------------------------------+

int Max (int val1, int val2) {

if (val1 > val2) return(val1);

return(val2);

}

[/CODE]

and this is mine:

[CODE]//+------------------------------------------------------------------+

//| Macd_with_EMA_BDv09_12_22.mq4 |

//| Jeff |

//| wolfboy@att.net |

//+------------------------------------------------------------------+

#property copyright "Jeff"

#property link "wolfboy@att.net"

#property indicator_separate_window

#property indicator_buffers 7

#property indicator_color1 LimeGreen

#property indicator_color2 LimeGreen

#property indicator_color3 Plum

#property indicator_color4 Plum

#property indicator_color5 CLR_NONE

#property indicator_color6 Black

#property indicator_color7 CLR_NONE

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

#property indicator_width4 2

#property indicator_width5 1

#property indicator_width6 1

#property indicator_width7 2

#property indicator_level1 0.0

#property indicator_levelcolor DimGray

#property indicator_levelstyle 0

//---- indicator parameters

extern int TimeFrame = 0;

extern int Nbars = 500;

extern int FastEMA = 10;

extern int SlowEMA = 20;

extern int SignalEMA = 1;

extern int MAofSignalPer = 7;

//---- indicator buffers

double green_buffer[];

double DarkGreen_buffer[];

double red_buffer[];

double Maroon_buffer[];

double MacdBuffer[];

double SignalBuffer[];

double MAofSignalBuffer[];

string IndicatorFileName;

string short_name;

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

//

//

//

//

//

int init()

{

//---- indicator buffers mapping

SetIndexBuffer(0,green_buffer);

SetIndexBuffer(1,DarkGreen_buffer);

SetIndexBuffer(2,red_buffer);

SetIndexBuffer(3,Maroon_buffer);

SetIndexBuffer(4,MacdBuffer);

SetIndexBuffer(5,SignalBuffer);

SetIndexBuffer(6,MAofSignalBuffer);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(4,DRAW_NONE);

SetIndexStyle(5,DRAW_LINE,STYLE_SOLID);

SetIndexStyle(6,DRAW_LINE,STYLE_DOT);

SetIndexDrawBegin(1,SignalEMA);

IndicatorDigits(Digits+1);

switch(TimeFrame)

{

case 1: string TimeFrameStr = "M1" ; break;

case 5 : TimeFrameStr = "M5" ; break;

case 15 : TimeFrameStr = "M15"; break;

case 30 : TimeFrameStr = "M30"; break;

case 60 : TimeFrameStr = "H1" ; break;

case 240 : TimeFrameStr = "H4" ; break;

case 1440 : TimeFrameStr = "D1" ; break;

case 10080 : TimeFrameStr = "W1" ; break;

case 43200 : TimeFrameStr = "MN1"; break;

default : TimeFrameStr = "TF0";

}

TimeFrame = MathMax(TimeFrame,Period());

IndicatorFileName = WindowExpertName();

short_name = ("MACD in color MTF ("+TimeFrameStr+")") ;

IndicatorShortName(short_name);

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int counted_bars = IndicatorCounted();

int limit, i;

if(counted_bars < 0) return(-1);

if(counted_bars > 0) counted_bars--;

limit = Nbars - counted_bars;

if (TimeFrame != Period())

{

limit = MathMax(limit,TimeFrame/Period());

for(i = 0; i < limit; i++)

{

int y = iBarShift(NULL,TimeFrame,Time);

green_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,0,y);

DarkGreen_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,1,y);

red_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,2,y);

Maroon_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,3,y);

MacdBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,4,y);

SignalBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,5,y);

MAofSignalBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,6,y);

}

return(0);

}

}

コードから、それは動作するはずです。

それは部分的なコードであるため、あなたはそれを期待とは異なることが起こっている正確に説明することができますか?

 
thefxpros:
こんにちは。

このコードの何が問題なのでしょうか?私は、ソースのインディケータからicustom関数を使用してmtfインディケータを取得しようとしています。いつ間違っているのかがわかりません。どこに間違いがあるのか教えてください。

私はそれがすでに新しいビルドのためにコード化されているこの指標を知っているが、そのmtfバージョンは、非標準の時間枠に適していないと私はそれらを必要としています。

ソースのインジケータ。

//+------------------------------------------------------------------+

//| Macd_with_EMA_BDv09_12_22.mq4 |

//| Jeff |

//| wolfboy@att.net |

//+------------------------------------------------------------------+

#property copyright "Jeff"

#property link "wolfboy@att.net"

#property indicator_separate_window

#property indicator_buffers 7

#property indicator_color1 LimeGreen

#property indicator_color2 LimeGreen

#property indicator_color3 Plum

#property indicator_color4 Plum

#property indicator_color5 CLR_NONE

#property indicator_color6 Black

#property indicator_color7 CLR_NONE

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

#property indicator_width4 2

#property indicator_width5 1

#property indicator_width6 1

#property indicator_width7 2

#property indicator_level1 0.0

#property indicator_levelcolor DimGray

#property indicator_levelstyle 0

//---- indicator parameters

extern int Nbars = 500;

extern int FastEMA = 10;

extern int SlowEMA = 20;

extern int SignalEMA = 1;

extern int MAofSignalPer = 7;

//---- indicator buffers

double green_buffer[];

double DarkGreen_buffer[];

double red_buffer[];

double Maroon_buffer[];

double MacdBuffer[];

double SignalBuffer[];

double MAofSignalBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

IndicatorBuffers(7);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(4,DRAW_NONE);

SetIndexStyle(5,DRAW_LINE,STYLE_SOLID);

SetIndexStyle(6,DRAW_LINE,STYLE_DOT);

SetIndexDrawBegin(1,SignalEMA);

IndicatorDigits(Digits+1);

//---- indicator buffers mapping

SetIndexBuffer(0,green_buffer);

SetIndexBuffer(1,DarkGreen_buffer);

SetIndexBuffer(2,red_buffer);

SetIndexBuffer(3,Maroon_buffer);

SetIndexBuffer(4,MacdBuffer);

SetIndexBuffer(5,SignalBuffer);

SetIndexBuffer(6,MAofSignalBuffer);

//---- name for DataWindow and indicator subwindow label

IndicatorShortName("MACD in color ("+FastEMA+", "+SlowEMA+", "+SignalEMA+", "+MAofSignalPer+")");

SetIndexLabel(4,"MACD in color");

SetIndexLabel(5,"Signal");

SetIndexLabel(6,"MAofSignal");

//---- initialization done

return(0);

}

//+------------------------------------------------------------------+

//| Moving Averages Convergence/Divergence |

//+------------------------------------------------------------------+

int start()

{

int limit, i;

double MACD;

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

limit=Nbars-counted_bars;

//---- macd

for(i=0; i<limit; i++)

MacdBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-

iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

//---- signal line

for(i=0; i<limit; i++)

SignalBuffer=iMAOnArray(MacdBuffer,Bars,SignalEMA,0,MODE_EMA,i);

//---- MA of signal

for(i=0; i<limit; i++)

MAofSignalBuffer=iMAOnArray(SignalBuffer,Bars,MAofSignalPer,0,MODE_EMA,i);

for (i = Bars - Max (counted_bars-1, 1); i>=0; i--)

{

MACD=MacdBuffer;

if(MACD>0)

{

if (MACD>MacdBuffer)

{

green_buffer = MACD;

DarkGreen_buffer = 0;

}

else

{

green_buffer = 0;

DarkGreen_buffer = MACD;

}

}

else

{

if (MACD<MacdBuffer)

{

red_buffer = 0;

Maroon_buffer = MACD;

}

else

{

red_buffer = MACD;

Maroon_buffer = 0;

}

}

}

//---- done

return(0);

}

//+------------------------------------------------------------------+

int Max (int val1, int val2) {

if (val1 > val2) return(val1);

return(val2);

}

[/CODE]

and this is mine:

[CODE]//+------------------------------------------------------------------+

//| Macd_with_EMA_BDv09_12_22.mq4 |

//| Jeff |

//| wolfboy@att.net |

//+------------------------------------------------------------------+

#property copyright "Jeff"

#property link "wolfboy@att.net"

#property indicator_separate_window

#property indicator_buffers 7

#property indicator_color1 LimeGreen

#property indicator_color2 LimeGreen

#property indicator_color3 Plum

#property indicator_color4 Plum

#property indicator_color5 CLR_NONE

#property indicator_color6 Black

#property indicator_color7 CLR_NONE

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

#property indicator_width4 2

#property indicator_width5 1

#property indicator_width6 1

#property indicator_width7 2

#property indicator_level1 0.0

#property indicator_levelcolor DimGray

#property indicator_levelstyle 0

//---- indicator parameters

extern int TimeFrame = 0;

extern int Nbars = 500;

extern int FastEMA = 10;

extern int SlowEMA = 20;

extern int SignalEMA = 1;

extern int MAofSignalPer = 7;

//---- indicator buffers

double green_buffer[];

double DarkGreen_buffer[];

double red_buffer[];

double Maroon_buffer[];

double MacdBuffer[];

double SignalBuffer[];

double MAofSignalBuffer[];

string IndicatorFileName;

string short_name;

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

//

//

//

//

//

int init()

{

//---- indicator buffers mapping

SetIndexBuffer(0,green_buffer);

SetIndexBuffer(1,DarkGreen_buffer);

SetIndexBuffer(2,red_buffer);

SetIndexBuffer(3,Maroon_buffer);

SetIndexBuffer(4,MacdBuffer);

SetIndexBuffer(5,SignalBuffer);

SetIndexBuffer(6,MAofSignalBuffer);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);

SetIndexStyle(4,DRAW_NONE);

SetIndexStyle(5,DRAW_LINE,STYLE_SOLID);

SetIndexStyle(6,DRAW_LINE,STYLE_DOT);

SetIndexDrawBegin(1,SignalEMA);

IndicatorDigits(Digits+1);

switch(TimeFrame)

{

case 1: string TimeFrameStr = "M1" ; break;

case 5 : TimeFrameStr = "M5" ; break;

case 15 : TimeFrameStr = "M15"; break;

case 30 : TimeFrameStr = "M30"; break;

case 60 : TimeFrameStr = "H1" ; break;

case 240 : TimeFrameStr = "H4" ; break;

case 1440 : TimeFrameStr = "D1" ; break;

case 10080 : TimeFrameStr = "W1" ; break;

case 43200 : TimeFrameStr = "MN1"; break;

default : TimeFrameStr = "TF0";

}

TimeFrame = MathMax(TimeFrame,Period());

IndicatorFileName = WindowExpertName();

short_name = ("MACD in color MTF ("+TimeFrameStr+")") ;

IndicatorShortName(short_name);

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int counted_bars = IndicatorCounted();

int limit, i;

if(counted_bars < 0) return(-1);

if(counted_bars > 0) counted_bars--;

limit = Nbars - counted_bars;

if (TimeFrame != Period())

{

limit = MathMax(limit,TimeFrame/Period());

for(i = 0; i < limit; i++)

{

int y = iBarShift(NULL,TimeFrame,Time);

green_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,0,y);

DarkGreen_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,1,y);

red_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,2,y);

Maroon_buffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,3,y);

MacdBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,4,y);

SignalBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,5,y);

MAofSignalBuffer = iCustom(NULL,TimeFrame,"MACD in color",Nbars,FastEMA,SlowEMA,SignalEMA,MAofSignalPer,6,y);

}

return(0);

}

}

私はちょうど解決しました。

 

エム

またお世話になります。

ソースインジケータ:ステップチャートage2 MTF

私のインジケーター:ステップチャートAge 2 MTF キャンドル

うまくいっているつもりなのですが、チャート上にプロットしても何も表示されません。トレンドバッファが原因だと思うのですが、どうすればいいのでしょうか。

ステップチャート_age_2_mtf_candles.mq4

ステップチャート_age_2_mtf.mq4

 
thefxpros:
ehm

またお世話になります。

ソース・インジケータ:ステップチャート・エイジ2・MTF

私のインジケーター:ステップチャートAge2 MTF ローソク足

うまくいっているつもりなのですが、チャート上にプロットしても何も表示されません。トレンドバッファが原因だと思うのですが、どうすればいいのでしょうか。

ステップチャート_age_2_mtf_candles.mq4

ステップチャート_age_2_mtf.mq4

thefxpros

ここに行く:step_chart_age_2_mtf_candles_1.mq4

ファイル:
 
mladen:
thefxpros はい、これです:step_chart_age_2_mtf_candles_1.mq4

ありがとうございます。

しかし、まだ何かが間違っている

ファイル:
cattura_1.jpg  90 kb
 
thefxpros:
ありがとうございます。

が、まだ何かおかしい

トレンド条件のチェックが 正しくありません。

trend > 0 and trend < 0 であるべきで、trend == 1 and trend == -1 ではありません。

ファイル:
 

これを試してみてはいかがでしょうか・・・。うまくいくといいのですが