编码帮助 - 页 202

 

无法在图表上移动文本输出而不出错?

目前的范围信息文本输出被价格蜡烛所覆盖。我的编码技能不足,每次尝试都以错误告终。我只是试图在图表上移动文本输出,如图所示。谁能帮帮我?非常感谢!!!蚂蚁-突破.mq4

附加的文件:
 
daytrade5:
目前的范围信息文本输出是由价格蜡烛覆盖的。我的编码能力不足,每次尝试都以错误告终。我只是想在图表上移动文本输出,如图所示。谁能帮帮我?非常感谢!!!蚂蚁-突破.mq4

Daytrade5

当使用metatrader 4时,我们不能选择文本类型对象的锚点(metatrader 4总是对这类对象使用固定的锚点,我们不能改变)。附上一个版本,可以修改文本的位置(使用TEXT_OFFSET),但有时你必须改变它的值,而且对齐方式也不是100%完美。

附加的文件:
 
mladen:
daytrade5 当使用metatrader 4时,我们不能选择文本类型对象的锚(metatrader 4总是对这种对象使用一个固定的锚,我们不能改变)。附上一个版本,可以修改文本的位置(使用TEXT_OFFSET),但有时你必须改变它的值,而且对齐方式也不是100%完美。

OK....,非常感谢你。我从来没有想过这个问题。

 

良好的停泊,请帮助解决这个订单警报mq4 - 当一个订单被关闭时,它会发送一个警报,但现在它为每个图表 上打开的每个符号发送警报,而不是只对相关符号采取行动。

请注意。

附加的文件:
 
zigflip:
好的停泊,请帮助解决这个订单警报MQ4--当一个订单被关闭时,它会发送一个警报,但现在它为每个图表上打开的每个符号发送警报,而不是只对相关符号采取行动。亲切的问候,

zigflip

现在就试试吧

附加的文件:
 

不知道如何从4个CIC中获取数值

你好。

我还有一个问题,第一个问题我已经解决了,谢谢你,Mladen

我在这里找到了mladen的4个Cci,我非常喜欢它,我知道它是重绘的,但它对我来说还是非常有用的。

我想把这4个值放到另一个自制的指标中,但我就是找不到方法。

我试着用前一页中的bool线和4cci中的值来做,但它对我不起作用。

我想对于有经验的代码来说,有一个简单的解决方案,但我已经花了很多时间,却没有想出办法。

谢谢你的建议

鲍勃

//------------------------------------------------------------------

#property copyright "mladen"

#property link "www.forex-tsd.cm"

//------------------------------------------------------------------

#属性 indicator_separate_window

#属性 indicator_buffers 8

#属性 indicator_color1 石灰绿

#属性 indicator_color2 PaleVioletRed

#属性 indicator_color3 石灰绿

#属性 indicator_color4 淡紫红 #属性 indicator_color4 淡紫红

#属性指示器_color5 青柠绿

#属性指示器_color6 淡紫红色 #属性指示器_color6 淡紫红色

#属性指示器_color7 青柠绿

#属性指示器_color8 淡紫红色 #属性指示器_color8 淡紫红色

#属性指示器_最小值 0

#属性 indicator_maximum 5

//

//

//

//

//

外部字符串 TimeFrame1 = "当前时间框架"。

extern string TimeFrame2 = "next1";

extern string TimeFrame3 = "next2";

extern string TimeFrame4 = "next3";

外置 int Period_CCI = 24;

外部字符串 UniqueID = "4个时间CCI斜率"。

外部int LinesWidth = 0;

外部颜色 LabelsColor = DarkGray;

外置 int LabelsHorizontalShift = 5;

外置双数 LabelsVerticalShift = 1.5;

外部 bool alertsOn = false;

外置 int alertsLevel = 3;

外部bool alertsMessage = FALSE;

外置 bool alertsSound = false;

外置ool alertsEmail = false;

//

//

//

//

//

双倍gosc1u[]。

双倍gosc1d[]。

双倍gosc2u[]。

双倍gosc2d[]。

双倍gosc3u[]。

双倍gosc3d[]。

双倍gosc4u[]。

双倍gosc4d[]。

int timeFrames[4];

bool returnBars。

字符串 indicatorFileName。

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init()

{

SetIndexBuffer(0,gosc1u);

SetIndexBuffer(1,gosc1d);

SetIndexBuffer(2,gosc2u);

SetIndexBuffer(3,gosc2d);

SetIndexBuffer(4,gosc3u);

SetIndexBuffer(5,gosc3d);

SetIndexBuffer(6,gosc4u);

SetIndexBuffer(7,gosc4d);

indicatorFileName = WindowExpertName();

returnBars = (TimeFrame1=="returnBars"); if (returnBars) return(0);

//

//

//

//

//

for (int i=0; i<8; i++)

{

SetIndexStyle(i,DRAW_ARROW,EMPTY,LinesWidth); SetIndexArrow(i,110);

}

timeFrames[0] = stringToTimeFrame(TimeFrame1);

timeFrames[1] = stringToTimeFrame(TimeFrame2);

timeFrames[2] = stringToTimeFrame(TimeFrame3);

timeFrames[3] = stringToTimeFrame(TimeFrame4);

alertsLevel = MathMin(MathMax(alertsLevel,3),4)。

IndicatorShortName(UniqueID)。

返回(0)。

}

int deinit()

{

for (int t=0; t<4; t++) ObjectDelete(UniqueID+t);

return(0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

double trend[][6];

#define _up 0

#define _dn 1

#define _hl1 2

#define _hl2 3

#define _hl3 4

#define _hl4 5

int start()

{

int i,r,count,counted_bars=IndicatorCounted()。

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

如果(counted_bars>0) counted_bars--。

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

if (returnBars) { gosc1u[0] = limit+1; return(0); }

如果 (timeFrames[0] != Period()) limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrames[0],indicatorFileName, "returnBars",0,0)*timeFrames[0]/Period() )。

如果 (timeFrames[1] != Period()) limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrames[1],indicatorFileName, "returnBars",0,0)*timeFrames[1]/Period() )。

如果 (timeFrames[2] != Period()) limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrames[2],indicatorFileName, "returnBars",0,0)*timeFrames[2]/Period() )。

如果 (timeFrames[3] != Period()) limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrames[3],indicatorFileName, "returnBars",0,0)*timeFrames[3]/Period() )。

如果(ArrayRange(trend,0)!=Bars) ArrayResize(trend,Bars)。

//

//

//

//

//

bool initialized = false;

if (!initialized)

{

initialized = true。

int window = WindowFind(UniqueID);

for (int t=0; t<4; t++)

{

string label = timeFrameToString(timeFrames[t]);

ObjectCreate(UniqueID+t,OBJ_TEXT,window,0,0)。

ObjectSet(UniqueID+t,OBJPROP_COLOR,LabelsColor)。

ObjectSet(UniqueID+t,OBJPROP_PRICE1,t+LabelsVerticalShift)。

ObjectSetText(UniqueID+t,label,8, "Arial")。

}

}

for (t=0; t<4; t++) ObjectSet(UniqueID+t,OBJPROP_TIME1,Time[0]+Period()*LabelsHorizontalShift*60) 。

//

//

//

//

//

for(i = limit, r=Bars-i-1; i >= 0; i--, r++)

{

trend[r][_up] = 0;

trend[r][_dn] = 0;

trend[r][_hl1] = trend[r-1][_hl1]。

trend[r][_hl2] = trend[r-1][_hl2];

trend[r][_hl3] = trend[r-1][_hl3];

trend[r][_hl4] = trend[r-1][_hl4]。

for (int k=0; k<4; k++)

{

int y = iBarShift(NULL,timeFrames[k],Time);

double cciNow = iCCI(NULL, timeFrames[k], Period_CCI, PRICE_TYPICAL, y);

double cciPre = iCCI(NULL, timeFrames[k], Period_CCI, PRICE_TYPICAL, y+1);

如果(ciNow>cciPre) trend[r][k+2] = 1。

如果 (ciNow<cciPre) trend[r][k+2] = -1;

switch (k)

{

case 0 : if (trendy[r][k+2]==1) { gosc1u = k+1; gosc1d = EMPTY_VALUE;} else { gosc1d = k+1; gosc1u = EMPTY_VALUE; } break;

case 1 : if (trendy[r][k+2]==1) { gosc2u = k+1; gosc2d = EMPTY_VALUE;} else { gosc2d = k+1; gosc2u = EMPTY_VALUE; } break;

case 2 : if (trendy[r][k+2]==1) { gosc3u = k+1; gosc3d = EMPTY_VALUE;} else { gosc3d = k+1; gosc3u = EMPTY_VALUE; } break;

case 3 : if (trend[r][k+2]==1) { gosc4u = k+1; gosc4d = EMPTY_VALUE;} else { gosc4d = k+1; gosc4u = EMPTY_VALUE; } break;

}

如果(trendice[r][k+2]==1)

trend[r][_up] +=1。

否则 trend[r][_dn] += 1;

}

}

manageAlerts()。

return(0);

}

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

//|

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

//

//

//

//

//

空白管理提示()。

{

如果(alertsOn)

{

int whichBar = Bars-1;

如果(趋势[whichBar][_up] >= alertsLevel ||趋势[whichBar][_dn] >= alertsLevel)。

{

如果(trend[whichBar][_up] >= alertsLevel) doAlert("up" ,trend[whichBar][_up])。

如果(trendy[whichBar][_dn] >= alertsLevel) doAlert("down",trendy[whichBar][_dn])。

}

}

}

//

//

//

//

//

void doAlert(string doWhat, int howMany)

{

静态字符串previousAlert="无"。

static datetime previousTime;

字符串信息。

如果(previousAlert != doWhat || previousTime != Time[0]) {

previousAlert = doWhat;

previousTime = Time[0];

//

//

//

//

//

message = Symbol()+" at "+TimeToStr(TimeLocal(),TIME_SECONDS)+" "+howMany+" time frames of MA trends are aligned "+doWhat;

if (alertsMessage) Alert(message);

如果(alertsEmail)SendMail(Symbol()+" 4个时间框架的MA趋势",message)。

如果(alertsSound) PlaySound("alert2.wav")。

}

}

//-------------------------------------------------------------------

//

//-------------------------------------------------------------------

//

//

//

//

//

string sTfTable[] = {"M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN" };

int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//

//

//

//

//

int toInt(double value) { return(value); }

int stringToTimeFrame(string tfs)

{

tfs = stringUpperCase(tfs);

int max = ArraySize(iTfTable)-1, add=0;

int nxt = (StringFind(tfs, "NEXT1")>-1); if (nxt>0) { tfs = ""+Period(); add=1; }

nxt = (StringFind(tfs, "NEXT2")>-1); if (nxt>0) { tfs = ""+Period(); add=2; }

nxt = (StringFind(tfs, "NEXT3")>-1); if (nxt>0) { tfs = ""+Period(); add=3; }

//

//

//

//

//

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

if (tfs==sTfTable || tfs==""+iTfTable) return(MathMax(iTfTable[toInt(MathMin(max,i+add))], Period())。

return(Period())。

}

string timeFrameToString(int tf)

{

for (int i=ArraySize(iTfTable)-1; i>=0; i--)

if (tf==iTfTable) return(sTfTable);

return("")。

}

//

//

//

//

//

stringUpperCase(string str)

{

string s = str;

for (int length=StringLen(str)-1; length>=0; length--)

{

int char = StringGetChar(s, length);

if((char > 96 && char 223 && char < 256))

s = StringSetChar(s, length, char - 32);

否则如果(char > -33 && char < 0)

s = StringSetChar(s, length, char + 224);

}

return(s);

}
 
BobMorane1000:
你好。

我还有一个问题,第一个问题我已经解决了,谢谢你,Mladen

我在这里找到了mladen的4个Cci,我非常喜欢它,我知道它是重绘的,但它对我来说仍然非常有效。

我想把这4个值放到另一个自制的指标中,但我就是找不到方法。

我试着用前一页中的bool线和4cci中的值来做,但它对我不起作用。

我想对于有经验的代码来说,有一个简单的解决方案,但我已经花了很多时间,却没有想出办法。

谢谢你的建议

鲍勃

BobMorane1000

你为什么不简单地用iCCI() 调用来代替4次呢(即使从代码上看也会简单得多)?

 

你是对的,我会这样做的。

再次感谢

 

谁能帮我在这个随机的十字架上添加箭头?

附加的文件:
 

[ATTACH]187655

嗨,我需要帮助。

我有一个很好的Trendindicatoe,它把蜡烛染成绿色并读出趋势。但它有一个错误:当改变时间框架时,它不能让颜色保持不变。但更糟糕的是,几乎看不到假发,我无法改变这一点。

谁能看一下?

非常感谢。我附上该指标

附加的文件:
t3_thv.ex4  5 kb