编码帮助 - 页 139

 

有什么办法可以正确发布代码吗?空格键不起作用,我不知道为什么。

 
RyuShin:
有什么办法可以正确地发布代码吗?空格键不起作用,我不知道为什么。

你可以像图片上显示的那样做(简单地将代码粘贴到php框中)。

或者你可以用普通的附件来附上代码

附加的文件:
 
mladen:
你可以按照图片上的方法(简单地将代码粘贴在php框中),或者你可以用普通的附件将代码附在上面。

问题是我没有看到这个盒子。我不知道为什么。我使用了Firefox和internet explorer,但它们都没有显示这个盒子 :/ 总之,我将使用另一台电脑再试一次。

 

好了,这里是指标的代码。

每周

#property indicator_chart_window

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

ObjectDelete("WS1");

ObjectDelete("WS2");

ObjectDelete("WS3");

ObjectDelete("WR1");

ObjectDelete("WR2");

ObjectDelete("WR3");

ObjectDelete("WEEKLY PIVOT");

ObjectDelete("Weekly Support 1");

ObjectDelete("Weekly 2");

ObjectDelete("Weekly 3");

ObjectDelete("Weekly Pivot level");

ObjectDelete("Weekly Resistance 1");

ObjectDelete("Weekly Resistance 2");

ObjectDelete("Weekly Resistance 3");

Comment(" ");

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

//----

double rates[1][6],weekly_close,weekly_high,weekly_low;

ArrayCopyRates(rates, Symbol(), PERIOD_W1);

if(DayOfWeek() == 1)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_W1,1)) == 5)

{

weekly_close = rates[1][4];

weekly_high = rates[1][3];

weekly_low = rates[1][2];

}

else

{

for(int d = 5;d>=0;d--)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_W1,d)) == 5)

{

weekly_close = rates[d][4];

weekly_high = rates[d][3];

weekly_low = rates[d][2];

}

}

}

}

else

{

weekly_close = rates[1][4];

weekly_high = rates[1][3];

weekly_low = rates[1][2];

}

//---- Calculate Pivots

Comment("\nWeekly quotations:\nH ",weekly_high,"\nL ",weekly_low, "\nC ",weekly_close);

double R = weekly_high - weekly_low;//range

double wp = (weekly_high + weekly_low + weekly_close)/3;// Standard Pivot

double wr3 = wp + (R * 1.000);

double wr2 = wp + (R * 0.618);

double wr1 = wp + (R * 0.382);

double ws1 = wp - (R * 0.382);

double ws2 = wp - (R * 0.618);

double ws3 = wp - (R * 1.000);

drawLine(wr3,"WR3", LimeGreen,0);

drawLabel(" WR 3",wr3,LimeGreen);

drawLine(wr2,"WR2", LimeGreen,0);

drawLabel(" WR 2",wr2,LimeGreen);

drawLine(wr1,"WR1", LimeGreen,0);

drawLabel(" WR 1",wr1,LimeGreen);

drawLine(wp,"WEEKLY PIVOT",Black,1);

drawLabel(" WP",wp,Black);

drawLine(ws1,"WS1",Crimson,0);

drawLabel(" WS 1",ws1,Crimson);

drawLine(ws2,"WS2",Crimson,0);

drawLabel(" WS 2",ws2,Crimson);

drawLine(ws3,"WS3",Crimson,0);

drawLabel(" WS 3",ws3,Crimson);

//----

return(0);

}

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

void drawLabel(string name,double lvl,color Color)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl);

ObjectSetText(name, name, 8, "Arial", EMPTY);

ObjectSet(name, OBJPROP_COLOR, Color);

}

else

{

ObjectMove(name, 0, Time[10], lvl);

}

}

void drawLine(double lvl,string name, color Col,int type)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

else

{

ObjectDelete(name);

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

}[/PHP]

Monthly

[PHP]//+------------------------------------------------------------------+

#property indicator_chart_window

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

ObjectDelete("MS1");

ObjectDelete("MS2");

ObjectDelete("MS3");

ObjectDelete("MR1");

ObjectDelete("MR2");

ObjectDelete("MR3");

ObjectDelete("MONTHLY PIVOT");

ObjectDelete("Monthly Support 1");

ObjectDelete("Monthly 2");

ObjectDelete("Monthly 3");

ObjectDelete("Monthly Pivot level");

ObjectDelete("Monthly Resistance 1");

ObjectDelete("Monthly Resistance 2");

ObjectDelete("Monthly Resistance 3");

Comment(" ");

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

//----

double rates[1][6],monthly_close,monthly_high,monthly_low;

ArrayCopyRates(rates, Symbol(), PERIOD_MN1);

if(DayOfWeek() == 1)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_MN1,1)) == 5)

{

monthly_close = rates[1][4];

monthly_high = rates[1][3];

monthly_low = rates[1][2];

}

else

{

for(int d = 5;d>=0;d--)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_MN1,d)) == 5)

{

monthly_close = rates[d][4];

monthly_high = rates[d][3];

monthly_low = rates[d][2];

}

}

}

}

else

{

monthly_close = rates[1][4];

monthly_high = rates[1][3];

monthly_low = rates[1][2];

}

//---- Calculate Pivots

Comment("\nMonthly quotations:\nH ",monthly_high,"\nL ",monthly_low, "\nC ",monthly_close);

double R = monthly_high - monthly_low;//range

double mp = (monthly_high + monthly_low + monthly_close)/3;// Standard Pivot

double mr3 = mp + (R * 1.000);

double mr2 = mp + (R * 0.618);

double mr1 = mp + (R * 0.382);

double ms1 = mp - (R * 0.382);

double ms2 = mp - (R * 0.618);

double ms3 = mp - (R * 1.000);

drawLine(mr3,"MR3", Lime,0);

drawLabel(" MR 3",mr3,Lime);

drawLine(mr2,"MR2", Lime,0);

drawLabel(" MR 2",mr2,Lime);

drawLine(mr1,"MR1", Lime,0);

drawLabel(" MR 1",mr1,Lime);

drawLine(mp,"MONTHLY PIVOT",Black,1);

drawLabel(" MP",mp,Black);

drawLine(ms1,"MS1",Red,0);

drawLabel(" MS 1",ms1,Red);

drawLine(ms2,"MS2",Red,0);

drawLabel(" MS 2",ms2,Red);

drawLine(ms3,"MS3",Red,0);

drawLabel(" MS 3",ms3,Red);

//----

return(0);

}

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

void drawLabel(string name,double lvl,color Color)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl);

ObjectSetText(name, name, 8, "Arial", EMPTY);

ObjectSet(name, OBJPROP_COLOR, Color);

}

else

{

ObjectMove(name, 0, Time[10], lvl);

}

}

void drawLine(double lvl,string name, color Col,int type)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

else

{

ObjectDelete(name);

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

}
 
RyuShin:
问题是我没有看到这个盒子。我不知道为什么。我使用了Firefox和Internet explorer,但它们都没有显示这个盒子 :/ 总之,我将使用另一台电脑再试一次。

龙信

你不会看到一个盒子,你会看到像这样的东西。

并会产生这样的结果。

paste your code here
附加的文件:
code_2.gif  35 kb
 

嗨,伙计们。

它非常简单,但我不知道为什么它不能按照我想要的方式工作。基本上我想检查 一个指标的两个连续值。如果它们是相同的,就在蜡烛收盘时画一个箭头。

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+2);

if ( (now==previous))

{

CrossUp=previous;

}

[/CODE]

The code above is not showing any arrows when it should (I checked in data window)

The parameters, indicators name is all working fine because with the following code, it is showing arrows

[CODE]

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+1);

if ( (now==previous))

{

CrossUp=previous;

}

谁能帮帮我,为什么第一组代码是不一样的?

数据窗口中的值是一样的!...

谢谢你的帮助!

 
yuhu:
嗨,伙计们。

它非常简单,但我不知道为什么它不能按照我想要的方式工作。基本上我想检查一个指标的两个连续值。如果它们是相同的,就在蜡烛收盘时画一个箭头。

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+2);

if ( (now==previous))

{

CrossUp=previous;

}

[/CODE]

The code above is not showing any arrows when it should (I checked in data window)

The parameters, indicators name is all working fine because with the following code, it is showing arrows

[CODE]

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+1);

if ( (now==previous))

{

CrossUp=previous;

}

谁能帮帮我,为什么第一组代码是不一样的?

数据窗口中的值是一样的!...

提前感谢您!

yuhu

如果没有用IndicatorDigits()函数进行不同的定义,数据窗口中的指标数据只显示为4位数的精度。没有显示的东西是导致你没有得到相等条件的原因。使用NormalizeDouble(),那么它应该更经常发生。

使用类似这样的东西。

if ( (NormalizeDouble(now,4)==NormalizeDouble(previous,4)))

或者使用一些其他的数字来代替4,你希望这些值被四舍五入到。

 

CSM的客观措施

你好

谁能帮我完成以下的编码。

在以下情况下提供一个警报

1 - 一种货币(例如下图中的欧元)在几个时间段内具有持续的高价值,并且

2 - 第二种货币(如图中的日元)在相同的时间段内有持续的低值。

例如,如果指定M15、M30、H1和H4(用户选择的时间段),警报将显示。

1 - 欧元的所有四个读数都是HiScore(一个变量,默认为70)或以上,并且

2 - 日元的所有四个读数均为LowScore(一个变量,默认为35)或更少。

("hanover --- 可扩展函数.mgh "和 "hanover --- 函数头.mgh "必须放在experts/include文件夹中才能正确看到图表。 我想它还需要在windows中安装 "PLCC___"字体,但我在这里没有成功上传该字体)。

谢谢你!"。

附加的文件:
 

非常感谢姆拉登,你是个英雄

保重!!

 

mladen,在我的metatrader过了0点之后,周线和月线中枢指标又开始工作了。我不知道为什么它们在星期一 不工作 :/ 无论如何,谢谢你的关注。