编码帮助 - 页 476

 

你好。

我需要一个指标,只在图表上放置一个固定的文本标签。

你能告诉我一个模型吗?

谢谢。

 
Jovager:
你好。

我需要一个指标,只在图表上放置一个固定的文本标签。

你能给我看一个模型吗。

谢谢。

你是否查看过这个主题:https://www.mql5.com/en/forum/179041

 
mladen:
Jo 你是否检查过这个主题:https://www.mql5.com/en/forum/179041

Mladen,

在该主题中,我发现了一个帖子,带来了 "TRO_MyNotes",这正是我需要的。

再次,Mladen,非常感谢你的帮助。

 

只是想知道是否有人能帮助解决这个问题(帖子#4739)?

谢谢。

 
godrich:
不知道我的要求是否可行,但就所附指标而言,是否有可能使出现在通道中的黄线变成 "真"?

我的意思是说,黄线不会平移/重新计算。

谢谢。

冈萨雷斯

它不能

它是一个Hodrick/Prescott滤波器--其本质是重新计算。有人尝试过这样做(比如说让它的末端变尖),但结果却与原来的不相上下

 

你好。

我试图用icustom函数 创建圆形ma MTF蜡烛指标。没有成功,也没有错误,但所附的指标却没有任何显示。请帮助我。谢谢。

源指标代码是这样的。

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

//| MAR.mq4 |

//| Copyright © 2014, Gehtsoft USA LLC |

//| http://fxcodebase.com |

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

#property copyright "Copyright © 2014, Gehtsoft USA LLC"

#property link "http://fxcodebase.com"

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 Orange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

extern int timeFrame = 0; // Time frame to use

extern int Length=8;

extern int Method=0; // 0 - SMA

// 1 - EMA

// 2 - SMMA

// 3 - LWMA

extern double Round=2;

extern int Price=0; // Applied price

// 0 - Close

// 1 - Open

// 2 - High

// 3 - Low

// 4 - Median

// 5 - Typical

// 6 - Weighted

extern int BarsToCalculate = 0;

double MAR[],MARda[],MARdb[],slope[] ;

double MA[], MovAle[];

double MaRo;

string indicatorFileName;

bool returnBars;

int init()

{

IndicatorShortName("Rounded ma MTF");

IndicatorBuffers(6);

SetIndexBuffer(0,MAR);

SetIndexBuffer(1,MARda);

SetIndexBuffer(2,MARdb);

SetIndexBuffer(3,MA);

SetIndexBuffer(4,MovAle);

SetIndexBuffer(5,slope);

indicatorFileName = WindowExpertName();

returnBars = timeFrame==-999; if (returnBars) return(0);

if (timeFrame==0) timeFrame= Period();

MaRo=Round*Point;

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int counted_bars=IndicatorCounted();

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

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

if (returnBars) { MAR[0] = MathMin(limit+1,Bars-1); return(0); }

if (timeFrame!=Period())

{

limit = (int)MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,-999,0,0)*timeFrame/Period()));

if (BarsToCalculate>0) limit = MathMin(limit,BarsToCalculate);

if (slope[limit]==-1) ClearPoint(limit,MARda,MARdb);

for (int i=limit; i>=0; i--)

{

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

MAR = iCustom(NULL,timeFrame,indicatorFileName,0,Length,Method,Round,Price,BarsToCalculate,0,y);

slope = iCustom(NULL,timeFrame,indicatorFileName,0,Length,Method,Round,Price,BarsToCalculate,5,y);

MARda = EMPTY_VALUE;

MARdb = EMPTY_VALUE;

if (slope == -1) PlotPoint(i,MARda,MARdb,MAR);

}

return(0);

}

//

//

//

//

//

if (BarsToCalculate>0) limit = MathMin(limit,BarsToCalculate);

if (slope[limit]==-1) ClearPoint(limit,MARda,MARdb);

for(int pos=limit; pos>=0; pos--)

{

MA[pos]=iMA(NULL, 0, Length, 0, Method, Price, pos);

if (MA[pos]>MA[pos+1]+MaRo || MA[pos]MAR[pos+1]+MaRo || MA[pos]MAR[pos+1] && MovAle[pos+1]==1.) || (MA[pos]<MAR[pos+1] && MovAle[pos+1]==-1.))

MAR[pos]=MA[pos];

else MAR[pos]=MAR[pos+1];

if (MAR[pos]<MAR[pos+1])

MovAle[pos]=-1.;

else

if (MAR[pos]>MAR[pos+1])

MovAle[pos]=1.;

else MovAle[pos]=MovAle[pos+1];

MARda[pos] = EMPTY_VALUE;

MARdb[pos] = EMPTY_VALUE;

slope[pos] = slope[pos+1];

if (MAR[pos]>MAR[pos+1]) slope[pos] = 1;

if (MAR[pos]<MAR[pos+1]) slope[pos] = -1;

if (slope[pos]==-1) PlotPoint(pos,MARda,MARdb,MAR);

}

return(0);

}

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

//| |

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

//

//

//

//

//

void ClearPoint(int i,double& first[],double& second[])

{

if ((second != EMPTY_VALUE) && (second != EMPTY_VALUE))

second = EMPTY_VALUE;

else

if ((first != EMPTY_VALUE) && (first != EMPTY_VALUE) && (first == EMPTY_VALUE))

first = EMPTY_VALUE;

}

//

//

//

//

//

void PlotPoint(int i,double& first[],double& second[],double& from[])

{

if (first == EMPTY_VALUE)

{

if (first == EMPTY_VALUE) {

first = from;

first = from;

second = EMPTY_VALUE;

}

else {

second = from;

second = from;

first = EMPTY_VALUE;

}

}

else

{

first = from;

second = EMPTY_VALUE;

}

}[/CODE]

and this is my indicator code:

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

//| MAR.mq4 |

//| Copyright © 2014, Gehtsoft USA LLC |

//| http://fxcodebase.com |

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

#property copyright "Copyright © 2014, Gehtsoft USA LLC"

#property link "http://fxcodebase.com"

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 Orange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

extern int timeFrame = 0;

extern int Length = 8;

extern int Method = 0;

extern double Round = 2;

extern int Price = 0;

extern int BarsToCalculate = 0;

extern color WickUpColor = DarkGreen;

extern color WickDnColor = FireBrick;

extern color BodyUpColor = LimeGreen;

extern color BodyDnColor = Orange;

extern int WickWidth = 1;

extern int BodyWidth = 2;

double UpBuffer[];

double DnBuffer[];

double UpbBuffer[];

double DnbBuffer[];

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

//| |

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

int init()

{

SetIndexBuffer(0,UpBuffer); SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, WickWidth, WickUpColor);

SetIndexBuffer(1,DnBuffer); SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, WickWidth, WickDnColor);

SetIndexBuffer(2,UpbBuffer); SetIndexStyle(2,DRAW_HISTOGRAM, EMPTY, BodyWidth, BodyUpColor);

SetIndexBuffer(3,DnbBuffer); SetIndexStyle(3,DRAW_HISTOGRAM, EMPTY, BodyWidth, BodyDnColor);

IndicatorShortName("Rounded ma MTF candles ("+timeFrame+","+Length+","+Round+")");

Length = MathMax(Length,1);

switch(timeFrame)

{

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

case 5 : TimeFrameStr="Period_M5"; break;

case 15 : TimeFrameStr="Period_M15"; break;

case 30 : TimeFrameStr="Period_M30"; break;

case 60 : TimeFrameStr="Period_H1"; break;

case 240 : TimeFrameStr="Period_H4"; break;

case 1440 : TimeFrameStr="Period_D1"; break;

case 10080 : TimeFrameStr="Period_W1"; break;

case 43200 : TimeFrameStr="Period_MN1"; break;

default : TimeFrameStr="Current Timeframe";

}

IndicatorShortName("Rounded ma MTF candles ("+TimeFrameStr+")");

return(0);

}

//----

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

//| MTF function |

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

int start()

{

int counted_bars=IndicatorCounted();

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

if(counted_bars>0) counted_bars--;

int limit = MathMin(MathMax(Bars-counted_bars,3*timeFrame/Period()),Bars-1);

for(int i=limit;i>=0;i--)

{

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

int slope=iCustom(Symbol(),timeFrame,"Rounded ma MTF",Length,Method,Round,Price,BarsToCalculate,5,y);

if (slope == 1) { UpBuffer=High; DnBuffer=Low; UpbBuffer = MathMax(Open,Close); DnbBuffer = MathMin(Open,Close); }

if (slope == -1) { DnBuffer=High; UpBuffer=Low; DnbBuffer = MathMax(Open,Close); UpbBuffer = MathMin(Open,Close); }

}

return(0);

}

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

 
thefxpros:
你好。

我试图用icustom函数创建圆形ma MTF蜡烛指标。没有成功,没有任何错误,但所附的指标却没有任何显示。请帮助我。谢谢。

源指标代码是这样的。

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

//| MAR.mq4 |

//| Copyright © 2014, Gehtsoft USA LLC |

//| http://fxcodebase.com |

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

#property copyright "Copyright © 2014, Gehtsoft USA LLC"

#property link "http://fxcodebase.com"

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 Orange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

extern int timeFrame = 0; // Time frame to use

extern int Length=8;

extern int Method=0; // 0 - SMA

// 1 - EMA

// 2 - SMMA

// 3 - LWMA

extern double Round=2;

extern int Price=0; // Applied price

// 0 - Close

// 1 - Open

// 2 - High

// 3 - Low

// 4 - Median

// 5 - Typical

// 6 - Weighted

extern int BarsToCalculate = 0;

double MAR[],MARda[],MARdb[],slope[] ;

double MA[], MovAle[];

double MaRo;

string indicatorFileName;

bool returnBars;

int init()

{

IndicatorShortName("Rounded ma MTF");

IndicatorBuffers(6);

SetIndexBuffer(0,MAR);

SetIndexBuffer(1,MARda);

SetIndexBuffer(2,MARdb);

SetIndexBuffer(3,MA);

SetIndexBuffer(4,MovAle);

SetIndexBuffer(5,slope);

indicatorFileName = WindowExpertName();

returnBars = timeFrame==-999; if (returnBars) return(0);

if (timeFrame==0) timeFrame= Period();

MaRo=Round*Point;

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int counted_bars=IndicatorCounted();

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

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

if (returnBars) { MAR[0] = MathMin(limit+1,Bars-1); return(0); }

if (timeFrame!=Period())

{

limit = (int)MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,-999,0,0)*timeFrame/Period()));

if (BarsToCalculate>0) limit = MathMin(limit,BarsToCalculate);

if (slope[limit]==-1) ClearPoint(limit,MARda,MARdb);

for (int i=limit; i>=0; i--)

{

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

MAR = iCustom(NULL,timeFrame,indicatorFileName,0,Length,Method,Round,Price,BarsToCalculate,0,y);

slope = iCustom(NULL,timeFrame,indicatorFileName,0,Length,Method,Round,Price,BarsToCalculate,5,y);

MARda = EMPTY_VALUE;

MARdb = EMPTY_VALUE;

if (slope == -1) PlotPoint(i,MARda,MARdb,MAR);

}

return(0);

}

//

//

//

//

//

if (BarsToCalculate>0) limit = MathMin(limit,BarsToCalculate);

if (slope[limit]==-1) ClearPoint(limit,MARda,MARdb);

for(int pos=limit; pos>=0; pos--)

{

MA[pos]=iMA(NULL, 0, Length, 0, Method, Price, pos);

if (MA[pos]>MA[pos+1]+MaRo || MA[pos]MAR[pos+1]+MaRo || MA[pos]MAR[pos+1] && MovAle[pos+1]==1.) || (MA[pos]<MAR[pos+1] && MovAle[pos+1]==-1.))

MAR[pos]=MA[pos];

else MAR[pos]=MAR[pos+1];

if (MAR[pos]<MAR[pos+1])

MovAle[pos]=-1.;

else

if (MAR[pos]>MAR[pos+1])

MovAle[pos]=1.;

else MovAle[pos]=MovAle[pos+1];

MARda[pos] = EMPTY_VALUE;

MARdb[pos] = EMPTY_VALUE;

slope[pos] = slope[pos+1];

if (MAR[pos]>MAR[pos+1]) slope[pos] = 1;

if (MAR[pos]<MAR[pos+1]) slope[pos] = -1;

if (slope[pos]==-1) PlotPoint(pos,MARda,MARdb,MAR);

}

return(0);

}

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

//| |

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

//

//

//

//

//

void ClearPoint(int i,double& first[],double& second[])

{

if ((second != EMPTY_VALUE) && (second != EMPTY_VALUE))

second = EMPTY_VALUE;

else

if ((first != EMPTY_VALUE) && (first != EMPTY_VALUE) && (first == EMPTY_VALUE))

first = EMPTY_VALUE;

}

//

//

//

//

//

void PlotPoint(int i,double& first[],double& second[],double& from[])

{

if (first == EMPTY_VALUE)

{

if (first == EMPTY_VALUE) {

first = from;

first = from;

second = EMPTY_VALUE;

}

else {

second = from;

second = from;

first = EMPTY_VALUE;

}

}

else

{

first = from;

second = EMPTY_VALUE;

}

}[/CODE]

and this is my indicator code:

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

//| MAR.mq4 |

//| Copyright © 2014, Gehtsoft USA LLC |

//| http://fxcodebase.com |

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

#property copyright "Copyright © 2014, Gehtsoft USA LLC"

#property link "http://fxcodebase.com"

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 Orange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

extern int timeFrame = 0;

extern int Length = 8;

extern int Method = 0;

extern double Round = 2;

extern int Price = 0;

extern int BarsToCalculate = 0;

extern color WickUpColor = DarkGreen;

extern color WickDnColor = FireBrick;

extern color BodyUpColor = LimeGreen;

extern color BodyDnColor = Orange;

extern int WickWidth = 1;

extern int BodyWidth = 2;

double UpBuffer[];

double DnBuffer[];

double UpbBuffer[];

double DnbBuffer[];

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

//| |

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

int init()

{

SetIndexBuffer(0,UpBuffer); SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, WickWidth, WickUpColor);

SetIndexBuffer(1,DnBuffer); SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, WickWidth, WickDnColor);

SetIndexBuffer(2,UpbBuffer); SetIndexStyle(2,DRAW_HISTOGRAM, EMPTY, BodyWidth, BodyUpColor);

SetIndexBuffer(3,DnbBuffer); SetIndexStyle(3,DRAW_HISTOGRAM, EMPTY, BodyWidth, BodyDnColor);

IndicatorShortName("Rounded ma MTF candles ("+timeFrame+","+Length+","+Round+")");

Length = MathMax(Length,1);

switch(timeFrame)

{

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

case 5 : TimeFrameStr="Period_M5"; break;

case 15 : TimeFrameStr="Period_M15"; break;

case 30 : TimeFrameStr="Period_M30"; break;

case 60 : TimeFrameStr="Period_H1"; break;

case 240 : TimeFrameStr="Period_H4"; break;

case 1440 : TimeFrameStr="Period_D1"; break;

case 10080 : TimeFrameStr="Period_W1"; break;

case 43200 : TimeFrameStr="Period_MN1"; break;

default : TimeFrameStr="Current Timeframe";

}

IndicatorShortName("Rounded ma MTF candles ("+TimeFrameStr+")");

return(0);

}

//----

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

//| MTF function |

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

int start()

{

int counted_bars=IndicatorCounted();

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

if(counted_bars>0) counted_bars--;

int limit = MathMin(MathMax(Bars-counted_bars,3*timeFrame/Period()),Bars-1);

for(int i=limit;i>=0;i--)

{

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

int slope=iCustom(Symbol(),timeFrame,"Rounded ma MTF",Length,Method,Round,Price,BarsToCalculate,5,y);

if (slope == 1) { UpBuffer=High; DnBuffer=Low; UpbBuffer = MathMax(Open,Close); DnbBuffer = MathMin(Open,Close); }

if (slope == -1) { DnBuffer=High; UpBuffer=Low; DnbBuffer = MathMax(Open,Close); UpbBuffer = MathMin(Open,Close); }

}

return(0);

}

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

替换为

slope=iCustom(Symbol(),timeFrame, "Rounded ma MTF",Length,Method,Round,Price,BarsToCalculate,5,y)。

slope=iCustom(Symbol(),timeFrame, "Rounded ma MTF",0,Length,Method,Round,Price,BarsToCalculate,5,y)。

 
mladen:
这是我在同一图表上将zup 150与江恩sq9 mxi nmc指标放在一起时得到的结果。

很感谢你,可能是我的错误,我也是从Poruchik得到的版本。

真诚地

 
zigflip:
很感谢你,可能是我的错误,我也从Poruchik那里得到了版本,真诚地感谢你

让我们知道发生了什么

也许只是一个特定的metatrader版本的问题(我目前使用788版本)。

 
mladen:
如你所知,ZigZag可以而且会重新绘制。

在重绘指标上使用警报(弹出窗口)作为信号是一件非常危险的事情,这也是我很久以前决定不做警报的原因--就我而言,最好不要在这样的指标上做警报,那么以后就不得不向不熟悉一些警报添加原因的人解释,为什么要在重绘指标上给出信号。

问候

谢谢你,先生。感谢你的答复