[警告关闭!]任何新手问题,为了不给论坛添乱。专业人士,不要走过。没有你,哪里都不能去。 - 页 198

 
SK. писал(а)>>

请看这里。

非常感谢SK,维宁!

是工作的好榜样。

一定是值得费尽心思去搞得这么复杂。:-)

看来,MQL4知道如何 "善待 "程序员的时间。:-)

 
SK. >> :

这里 .

谢谢你,非常有用的文章。

 
stera писал(а)>>

非常感谢SK,Vinin!

granit77 写道>>

谢谢你,非常有用的文章。

如果你对这个话题感兴趣,可以看看这篇文章http://www.forextrade.ru/mqlabs/sozdaniie-indikatora-kaghi

它讨论了水平线的很多细节,并展示了技术解决方案(交替)。

竖线也被说明了。但我仍然没有理解一些规则。例如,随着图像的晃动,改变个别缓冲区的奇偶性就足够了(第4-5块,将缓冲区的数量从6和7改为5和6,并使第5块成为7米)。

 
一个初学者的问题。是否有可能在mql4 中写一个EA,暗示自动交易,定期在某个小时开盘和收盘?我想测试一下。大多是用rulang,但这些想法在那里显然是不可行的。
 

各项指标和专家的顺序是什么?

我在一个图表上有两个指标。

而从总体上看,它们的执行时间有时要远远长于两点之间的时间。

哪个指标先被执行?

如果它们不是平行执行的,也许把它们放在不同的图表中是合理的,当然,如果不同的图表中没有执行顺序的话。

如果它们在同一个图表上,哪个指标或专家顾问先被执行,如果它们在不同的图表上?

 

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i]。

这是不可行的。


请告诉我该怎么做。我不知道该怎么做。

 
Feonix >> :

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i]。

这是不可行的。

请告诉我该怎么做。我不知道该怎么做。

>> 怎么办?>> 显示所有代码!

 
OneDepo >> :

该怎么做?显示所有的代码!

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

//| Momentum.mq4 |

//| Copyright © 2004, MetaQuotes Software Corp.

//| http://www.metaquotes.net/ |

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

#property copyright "Copyright © 2004, MetaQuotes Software Corp.

#属性链接 "http://www.metaquotes.net/"


#属性 indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

//---- 输入参数

外置 int MomPeriod=14;

int ret;

双倍x[]。

//---- 缓冲区

双倍MomBuffer[]。

双重ocfor[]。

双倍octen[]。

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

//|自定义指标初始化功能

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

int init()

{

string short_name;

//---- 指标线

SetIndexStyle(0,DRAW_LINE)。

SetIndexBuffer(0,MomBuffer)。

//---- DataWindow和指标子窗口标签的名称

short_name="Mom("+MomPeriod+")"。

IndicatorShortName(short_name)。

SetIndexLabel(0,short_name)。

//----

SetIndexDrawBegin(0,MomPeriod)。

//----

return(0);

}

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

//| 势头 |

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

int start()

{

int i,counted_bars=IndicatorCounted()。

//----

如果(Bars<=MomPeriod)返回(0)。

//----

i=Bars。

while(i>=0)

{

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i]。

i--;


}

return(0);

}

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



如果你用Double x;代替Double x[];,一切都能正常工作,但重点是分配mombuffer[i]=x[i]。

 
Feonix писал(а)>>

//+------------------------------------------------------------------+
//| Momentum.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"


#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue

//---- input parameters

extern int MomPeriod=14;

int ret;
double x[];

//---- buffers
double MomBuffer[];
double ocfor[];
double octen[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+

int init()
{
string short_name;
//---- indicator line
IndicatorBuffers( 2);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, MomBuffer);
SetIndexBuffer(1, x);

//---- name for DataWindow and indicator subwindow label
short_name="Mom("+ MomPeriod+")";
IndicatorShortName( short_name);
SetIndexLabel(0, short_name);

//----
SetIndexDrawBegin(0, MomPeriod);

//----
return(0);

}

//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+

int start()
{
int i, counted_bars=IndicatorCounted();

//----
if(Bars<= MomPeriod) return(0);
//----
i=Bars;

while( i>=0)
{
x[ i]=(Open[ i]-Close[ i]);
MomBuffer[ i]= x[ i];
i--;
}

return(0);
}

//+------------------------------------------------------------------+
你可以这样做
 
Feonix >> :

.

.

int start()

{

int i,counted_bars=IndicatorCounted()。

//----

如果(Bars<=MomPeriod)返回(0)。

//----

i=Bars。


ArrayResize(x, i+1);


while(i>=0)

{

x[i]=(Open[i]-Close[i]);

MomBuffer[i]=x[i]。

i--;

}

return(0);

}



如果你用Double x;代替Double x[];,一切都能正常工作,但关键是要把mombuffer[i]=x[i]赋值。

你声明了一个数组,但没有为它分配内存。

Vinin 给出了一种分配内存的方法 ,你可以使用第二种,通过 ArrayResize()函数来分配。

原因: