新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 117 1...110111112113114115116117118119120121122123124...1953 新评论 Artyom Trishkin 2017.02.09 18:44 #1161 Rustam Bikbulatov: 我是否要为它付钱? 好吧,如果有很多时间的人可以做到这一点,你可能会很幸运。但除此之外,是的,时间就是金钱,抱歉;) 或者尝试自己做,你会在这里得到帮助--帮助只针对那些自学的人,在某方面失败了。 Rustam Bikbulatov 2017.02.09 18:47 #1162 Artyom Trishkin: 开始写作。有什么问题--问吧--我们会帮忙。 还是你想让我们为你做这件事? 我想连接这些指标,但有一个错误。 我已经挣扎了一整天了 附加的文件: Moving_Averages.mq4 11 kb tyyu.mq4 5 kb Artyom Trishkin 2017.02.09 18:54 #1163 Rustam Bikbulatov: 我一直在尝试连接这些指标,但有一个错误。 我已经弄了一整天了。 给我看看你的代码,你在哪里试图连接它们,有什么问题? 请用SRC按钮粘贴代码,看看你想做什么,而不是把这些代码上传到你的系统,它们已经太多了。 Rustam Bikbulatov 2017.02.09 18:54 #1164 Rustam Bikbulatov: 我试图连接这些指标,但有一个错误出来了。'start' -函数 已经定义,并且有正文 sound Moving Averages.mq4 178 5 附加的文件: 3co2_Moving_Averages.mq4 13 kb Rustam Bikbulatov 2017.02.09 18:55 #1165 Artyom Trishkin: 显示你的代码,你在哪里试图连接它们,你失败的原因是什么? 请使用SRC按钮查看你要做的事情,而不是将这些代码上传到你的系统中--已经有太多的代码了。 我希望我知道那个神奇的按钮是什么。 Vitaly Muzichenko 2017.02.09 19:05 #1166 Rustam Bikbulatov: 如果我知道那个神奇的按钮是什么。哦,好吧。请阅读关于如何使用论坛的帮助。你想要一个链接,还是你能自己找到它? Rustam Bikbulatov 2017.02.09 19:09 #1167 //+------------------------------------------------------------------+//| Custom Moving Average.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_chart_window#property indicator_buffers 1#property indicator_color1 Red//---- indicator parametersextern int MA_Period=13;extern int MA_Shift=0;extern int MA_Method=0;extern double Alert_Level = 0;//---- indicator buffersdouble ExtMapBuffer[];double Buffer2[];//----int ExtCountedBars=0;int br1=0;//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init() { int draw_begin; string short_name;//---- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexShift(0,MA_Shift); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); if(MA_Period<2) MA_Period=13; draw_begin=MA_Period-1;//---- indicator short name switch(MA_Method) { case 1 : short_name="EMA("; draw_begin=0; break; case 2 : short_name="SMMA("; break; case 3 : short_name="LWMA("; break; default : MA_Method=0; short_name="SMA("; } IndicatorShortName(short_name+MA_Period+")"); SetIndexDrawBegin(0,draw_begin);//---- indicator buffers mapping SetIndexBuffer(0,ExtMapBuffer);//---- initialization done return(0); }//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+int start() { if(Bars<=MA_Period) return(0); ExtCountedBars=IndicatorCounted();//---- check for possible errors if (ExtCountedBars<0) return(-1);//---- last counted bar will be recounted if (ExtCountedBars>0) ExtCountedBars--;//---- switch(MA_Method) { case 0 : sma(); break; case 1 : ema(); break; case 2 : smma(); break; case 3 : lwma(); }//---- done return(0); }//+------------------------------------------------------------------+//| Simple Moving Average |//+------------------------------------------------------------------+void sma() { double sum=0; int i,pos=Bars-ExtCountedBars-1;//---- initial accumulation if(pos<MA_Period) pos=MA_Period; for(i=1;i<MA_Period;i++,pos--) sum+=Close[pos];//---- main calculation loop while(pos>=0) { sum+=Close[pos]; ExtMapBuffer[pos]=sum/MA_Period; sum-=Close[pos+MA_Period-1]; pos--; }//---- zero initial bars if(ExtCountedBars<1) for(i=1;i<MA_Period;i++) ExtMapBuffer[Bars-i]=0; }//+------------------------------------------------------------------+//| Exponential Moving Average |//+------------------------------------------------------------------+void ema() { double pr=2.0/(MA_Period+1); int pos=Bars-2; if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;//---- main calculation loop while(pos>=0) { if(pos==Bars-2) ExtMapBuffer[pos+1]=Close[pos+1]; ExtMapBuffer[pos]=Close[pos]*pr+ExtMapBuffer[pos+1]*(1-pr); pos--; } }//+------------------------------------------------------------------+//| Smoothed Moving Average |//+------------------------------------------------------------------+void smma() { double sum=0; int i,k,pos=Bars-ExtCountedBars+1;//---- main calculation loop pos=Bars-MA_Period; if(pos>Bars-ExtCountedBars) pos=Bars-ExtCountedBars; while(pos>=0) { if(pos==Bars-MA_Period) { //---- initial accumulation for(i=0,k=pos;i<MA_Period;i++,k++) { sum+=Close[k]; //---- zero initial bars ExtMapBuffer[k]=0; } } else sum=ExtMapBuffer[pos+1]*(MA_Period-1)+Close[pos]; ExtMapBuffer[pos]=sum/MA_Period; pos--; } }//+------------------------------------------------------------------+//| Linear Weighted Moving Average |//+------------------------------------------------------------------+void lwma() { double sum=0.0,lsum=0.0; double price; int i,weight=0,pos=Bars-ExtCountedBars-1;//---- initial accumulation if(pos<MA_Period) pos=MA_Period; for(i=1;i<=MA_Period;i++,pos--) { price=Close[pos]; sum+=price*i; lsum+=price; weight+=i; }//---- main calculation loop pos++; i=pos+MA_Period; while(pos>=0) { ExtMapBuffer[pos]=sum/weight; if(pos==0) break; pos--; i--; price=Close[pos]; sum=sum-lsum+price*MA_Period; lsum-=Close[i]; lsum+=price; }//---- zero initial bars if(ExtCountedBars<1) for(i=1;i<MA_Period;i++) ExtMapBuffer[Bars-i]=0; }//+------------------------------------------------------------------+int start() {int limit; int counted_bars = IndicatorCounted();//---- check for possible errors if(counted_bars < 0) return(-1);//---- last counted bar will be recounted if(counted_bars > 0) counted_bars--; limit = Bars - counted_bars; if(counted_bars==0) limit--;//---- for(int i = limit; i >=0; i--) //for(int i = 1000; i >=0; i--) { Buffer2[i]=iMA(NULL,1,60,0,1,6,0); } if(((Buffer2[2]<0 && Buffer2[1]>Alert_Level) || (Buffer2[2]>0 && Buffer2[1]<Alert_Level)) && br1<Bars ) { PlaySound("alert.wav"); Sleep(500); PlaySound("alert.wav"); Sleep(500); PlaySound("alert.wav"); br1=Bars; Alert("На ",Symbol()," \"", "\" пересечение с =0= "); Print("На ",Symbol()," \"", "\" пересечение с =0= "); } }//+------------------------------------------------------------------+ Any questions from newcomers 想做一个另类的移动平均线指标(Moving Average),请大家高手指导。 Experts: NirvamanImax Mickey Moose 2017.02.09 19:37 #1168 另一件趣事双重OP=5.00000TP=(OP/100)。Print("TP=",TP)。2017.02.09 21:36:03.650 2015.01.05 04:00:00 martin H1-1 USDJPY,H1: TP= 0.5我不明白,什么时候5除以100才是0.5?我已经弄明白了--由于某种原因,终端不支持不同的颜色,它只是采用其他函数中已有的颜色。 Artyom Trishkin 2017.02.09 19:40 #1169 trader781:...终端不支持不同的颜色,并采取了其他函数中已经存在的东西。 在物体中?胡说八道。 Mickey Moose 2017.02.09 19:43 #1170 Artyom Trishkin: 物品?胡说八道。 Artyom,我在上面抛出的代码 1...110111112113114115116117118119120121122123124...1953 新评论 原因: 取消 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
我是否要为它付钱?
或者尝试自己做,你会在这里得到帮助--帮助只针对那些自学的人,在某方面失败了。
开始写作。有什么问题--问吧--我们会帮忙。
还是你想让我们为你做这件事?
我一直在尝试连接这些指标,但有一个错误。 我已经弄了一整天了。
请用SRC按钮粘贴代码,看看你想做什么,而不是把这些代码上传到你的系统,它们已经太多了。
我试图连接这些指标,但有一个错误出来了。
显示你的代码,你在哪里试图连接它们,你失败的原因是什么?
请使用SRC按钮查看你要做的事情,而不是将这些代码上传到你的系统中--已经有太多的代码了。
如果我知道那个神奇的按钮是什么。
哦,好吧。
请阅读关于如何使用论坛的帮助。你想要一个链接,还是你能自己找到它?
//| Custom Moving Average.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_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- indicator parameters
extern int MA_Period=13;
extern int MA_Shift=0;
extern int MA_Method=0;
extern double Alert_Level = 0;
//---- indicator buffers
double ExtMapBuffer[];
double Buffer2[];
//----
int ExtCountedBars=0;
int br1=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexShift(0,MA_Shift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(MA_Period<2) MA_Period=13;
draw_begin=MA_Period-1;
//---- indicator short name
switch(MA_Method)
{
case 1 : short_name="EMA("; draw_begin=0; break;
case 2 : short_name="SMMA("; break;
case 3 : short_name="LWMA("; break;
default :
MA_Method=0;
short_name="SMA(";
}
IndicatorShortName(short_name+MA_Period+")");
SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if(Bars<=MA_Period) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
//----
switch(MA_Method)
{
case 0 : sma(); break;
case 1 : ema(); break;
case 2 : smma(); break;
case 3 : lwma();
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
//| Simple Moving Average |
//+------------------------------------------------------------------+
void sma()
{
double sum=0;
int i,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
if(pos<MA_Period) pos=MA_Period;
for(i=1;i<MA_Period;i++,pos--)
sum+=Close[pos];
//---- main calculation loop
while(pos>=0)
{
sum+=Close[pos];
ExtMapBuffer[pos]=sum/MA_Period;
sum-=Close[pos+MA_Period-1];
pos--;
}
//---- zero initial bars
if(ExtCountedBars<1)
for(i=1;i<MA_Period;i++) ExtMapBuffer[Bars-i]=0;
}
//+------------------------------------------------------------------+
//| Exponential Moving Average |
//+------------------------------------------------------------------+
void ema()
{
double pr=2.0/(MA_Period+1);
int pos=Bars-2;
if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
//---- main calculation loop
while(pos>=0)
{
if(pos==Bars-2) ExtMapBuffer[pos+1]=Close[pos+1];
ExtMapBuffer[pos]=Close[pos]*pr+ExtMapBuffer[pos+1]*(1-pr);
pos--;
}
}
//+------------------------------------------------------------------+
//| Smoothed Moving Average |
//+------------------------------------------------------------------+
void smma()
{
double sum=0;
int i,k,pos=Bars-ExtCountedBars+1;
//---- main calculation loop
pos=Bars-MA_Period;
if(pos>Bars-ExtCountedBars) pos=Bars-ExtCountedBars;
while(pos>=0)
{
if(pos==Bars-MA_Period)
{
//---- initial accumulation
for(i=0,k=pos;i<MA_Period;i++,k++)
{
sum+=Close[k];
//---- zero initial bars
ExtMapBuffer[k]=0;
}
}
else sum=ExtMapBuffer[pos+1]*(MA_Period-1)+Close[pos];
ExtMapBuffer[pos]=sum/MA_Period;
pos--;
}
}
//+------------------------------------------------------------------+
//| Linear Weighted Moving Average |
//+------------------------------------------------------------------+
void lwma()
{
double sum=0.0,lsum=0.0;
double price;
int i,weight=0,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
if(pos<MA_Period) pos=MA_Period;
for(i=1;i<=MA_Period;i++,pos--)
{
price=Close[pos];
sum+=price*i;
lsum+=price;
weight+=i;
}
//---- main calculation loop
pos++;
i=pos+MA_Period;
while(pos>=0)
{
ExtMapBuffer[pos]=sum/weight;
if(pos==0) break;
pos--;
i--;
price=Close[pos];
sum=sum-lsum+price*MA_Period;
lsum-=Close[i];
lsum+=price;
}
//---- zero initial bars
if(ExtCountedBars<1)
for(i=1;i<MA_Period;i++) ExtMapBuffer[Bars-i]=0;
}
//+------------------------------------------------------------------+
int start()
{int limit;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
if(counted_bars==0) limit--;
//----
for(int i = limit; i >=0; i--)
//for(int i = 1000; i >=0; i--)
{
Buffer2[i]=iMA(NULL,1,60,0,1,6,0);
}
if(((Buffer2[2]<0 && Buffer2[1]>Alert_Level) ||
(Buffer2[2]>0 && Buffer2[1]<Alert_Level)) && br1<Bars )
{
PlaySound("alert.wav"); Sleep(500);
PlaySound("alert.wav"); Sleep(500);
PlaySound("alert.wav"); br1=Bars;
Alert("На ",Symbol()," \"", "\" пересечение с =0= ");
Print("На ",Symbol()," \"", "\" пересечение с =0= ");
}
}
//+------------------------------------------------------------------+
另一件趣事
双重OP=5.00000
TP=(OP/100)。
Print("TP=",TP)。
2017.02.09 21:36:03.650 2015.01.05 04:00:00 martin H1-1 USDJPY,H1: TP= 0.5
我不明白,什么时候5除以100才是0.5?
我已经弄明白了--由于某种原因,终端不支持不同的颜色,它只是采用其他函数中已有的颜色。
...
终端不支持不同的颜色,并采取了其他函数中已经存在的东西。
物品?胡说八道。