编码帮助 - 页 329 1...322323324325326327328329330331332333334335336...786 新评论 mj023 2014.08.23 14:25 #3281 试着把这个附在日线图上,请告诉我你是否能根据这个指标做一个EA。 Mladen Rakic 2014.08.23 16:23 #3282 mj023: 试着把这个附在日线图上,请告诉我你是否能基于这个指标做一个EA。 我明白了 这是一个基于标签的指标,不可能有信号(知道前值和现值)。意思是:没有信号可以使用,EA也不能唯一地识别信号。对不起,没有多余的EA可能性。 Fausto Nunziante Del Gaudio 2014.08.24 11:50 #3283 嗨。 这段代码有什么问题?我试图用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); } } Coding help [警告关闭!]任何新手问题,为了不给论坛添乱。专业人士,不要走过。没有你,哪里都不能去。 跪求代码解读注解 本人刚接触mql4,实在不懂,求大神或好心人帮忙解读代码 Mladen Rakic 2014.08.24 15:45 #3284 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); } } 从代码上看,它应该可以工作 既然是部分代码,你能解释一下到底发生了什么,与你预期的不同吗? Fausto Nunziante Del Gaudio 2014.08.24 15:45 #3285 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); } } 我刚刚解决了。 Fausto Nunziante Del Gaudio 2014.08.25 08:29 #3286 嗯 我需要另一个帮助。 来源指标:阶梯图年龄2MTF 我的指标:阶梯图年龄2 MTF 蜡烛 我认为我做得很好,但我的指标在图表上绘制时没有显示任何东西。我想这取决于源指标的趋势缓冲,但我不知道如何继续。 step_chart_age_2_mtf_candles.mq4 step_chart_age_2_mtf.mq4 附加的文件: step_chart_age_2_mtf_candles.mq4 5 kb step_chart_age_2_mtf.mq4 9 kb Mladen Rakic 2014.08.25 11:08 #3287 thefxpros: ehm 我需要另一个帮助。 来源指标:阶梯图年龄2MTF 我的指标:阶梯图年龄2 MTF 蜡烛 我认为我做得很好,但我的指标在图表上绘制时没有显示任何东西。我想这取决于源指标的趋势缓冲,但我不知道如何继续。 step_chart_age_2_mtf_candles.mq4 步骤_图表_年龄_2_mtf.mq4 Thefxpros 给你:step_chart_age_2_mtf_candles_1.mq4 附加的文件: step_chart_age_2_mtf_candles_1.mq4 5 kb Fausto Nunziante Del Gaudio 2014.08.25 11:18 #3288 mladen: thefxpros 给你:step_chart_age_2_mtf_candles_1.mq4 谢谢。 但仍有一些问题 附加的文件: cattura_1.jpg 90 kb Mladen Rakic 2014.08.25 11:25 #3289 thefxpros: 谢谢。 但仍有一些问题 你对趋势条件的检查 是错误的 应该是趋势>0和趋势<0,而不是趋势==1和趋势==-1 附加的文件: step_ma_bars.gif 65 kb AZRUL FYZEE AZMI 2014.08.25 11:54 #3290 你可以试试这个....希望它能帮助你 附加的文件: captureaa.jpg 69 kb step_chart_age_2_mtf-1.01.mq4 9 kb step_chart_age_2_mtf_candles-1.01.mq4 9 kb 1...322323324325326327328329330331332333334335336...786 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
试着把这个附在日线图上,请告诉我你是否能根据这个指标做一个EA。
试着把这个附在日线图上,请告诉我你是否能基于这个指标做一个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);
}
}你好。
这段代码有什么问题?我试图从源指标中使用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);
}
}从代码上看,它应该可以工作
既然是部分代码,你能解释一下到底发生了什么,与你预期的不同吗?
你好。
这段代码有什么问题?我试图从源指标中使用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);
}
}我刚刚解决了。
嗯
我需要另一个帮助。
来源指标:阶梯图年龄2MTF
我的指标:阶梯图年龄2 MTF 蜡烛
我认为我做得很好,但我的指标在图表上绘制时没有显示任何东西。我想这取决于源指标的趋势缓冲,但我不知道如何继续。
step_chart_age_2_mtf_candles.mq4
step_chart_age_2_mtf.mq4
ehm
我需要另一个帮助。
来源指标:阶梯图年龄2MTF
我的指标:阶梯图年龄2 MTF 蜡烛
我认为我做得很好,但我的指标在图表上绘制时没有显示任何东西。我想这取决于源指标的趋势缓冲,但我不知道如何继续。
step_chart_age_2_mtf_candles.mq4
步骤_图表_年龄_2_mtf.mq4Thefxpros
给你:step_chart_age_2_mtf_candles_1.mq4
thefxpros 给你:step_chart_age_2_mtf_candles_1.mq4
谢谢。
但仍有一些问题
谢谢。
但仍有一些问题
你对趋势条件的检查 是错误的
应该是趋势>0和趋势<0,而不是趋势==1和趋势==-1
你可以试试这个....希望它能帮助你