顺水外汇EA交易网MT4
标题:
求修改指标,感谢
[打印本页]
作者:
看好了是真的
时间:
2018-1-11 13:17
标题:
求修改指标,感谢
这是一个MACD穿越0轴线后箭头加声音报警的指标,但是报警总是在穿越完成后下一根K线才报警,求大神给修改后穿越后立即报警的,感谢
/*
V1.2 2015-05-02
--- 货币对的报警加上货币对名称
--- 新增Alert_Enable和SendMail_Enable开头
V1.3 2015-05-02
--- 加了#property strict后在15钟或以上的图上不显示柱线,所以去掉了。原因不明。
V1.4 2015-05-04
--- 货币对的报警时加上周期
*/
//+------------------------------------------------------------------+
//| MACD_OsMA_ColorLH.mq4 |
//| Copyright ?2004, MetaQuotes Software Corp. |
//| mod. Variable MA settings http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
// 2008forextsd mtf keris f-la ki
#property copyright "Copyright ?2004, MetaQuotes Software Corp.";
#property link "http://www.metaquotes.net/"
//#property strict
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_color3 C'83,0,0' //Maroon
#property indicator_color4 C'0,66,0' //DarkGreen
#property indicator_color5 DodgerBlue
#property indicator_color6 Chocolate
#property indicator_color7 Red
#property indicator_color8 LimeGreen
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 1
#property indicator_width6 1
//---- indicator buffers
extern int TimeFrame = 0;
extern int FastMA_Period=12;
extern int SlowMA_Period=26;
extern int SignalMA_Period=9;
extern int FastMA_Mode=1;
extern int SlowMA_Mode=1;
extern int SignalMA_Mode=0;
extern int FastMA_Price=0;
extern int SlowMA_Price=0;
//extern int SignalMA_Price=0; // ma on array - price Close only
extern double OsmaMultiplier = 1.8;
extern bool ShowOsMA_Histo = true;
extern bool ShowMACD_Histo = false;
extern int MaxBarsToCount = 30000;
extern bool Alert_Enable = true; // 启用弹框警告
extern bool SendMail_Enable = false; // 启用邮件通知
extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string note_AppliedPrice = "0C,1O 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string note_MA_Mode = "SMA0 EMA1 SMMA2 LWMA3";
extern string note_defaults = "AO:34,5;SMA
[attach]17614[/attach]
riceMedian(4);MACD 12 26 9 EMA Close;SignalLinePrice- Close only(MaOnArray) ";
datetime g_last_alert_datetime;
datetime g_last_bar_changed_alert_datetime;
double ind_buffer1[], ind_buffer1s[];
double ind_buffer2[], ind_buffer2s[];
double ind_buffer3[];
double ind_buffer4[];
double ind_buffer5[];
double ind_buffer6[];
double ind_buffer_line_up_flag[];
double ind_buffer_line_down_flag[];
bool g_first_run = true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
g_first_run = true;
//---- additional buffer used for counting.
IndicatorBuffers(10);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_HISTOGRAM);
SetIndexStyle(4,DRAW_LINE);
SetIndexStyle(5,DRAW_LINE);
SetIndexStyle(6,DRAW_ARROW);
SetIndexStyle(7,DRAW_ARROW);
IndicatorDigits(Digits+2);
SetIndexDrawBegin(0,SlowMA_Period);
SetIndexDrawBegin(1,SlowMA_Period);
SetIndexDrawBegin(2,SlowMA_Period);
SetIndexDrawBegin(3,SlowMA_Period);
SetIndexDrawBegin(4,SlowMA_Period);
SetIndexDrawBegin(5,SlowMA_Period);
//---- indicator buffers mapping
SetIndexBuffer(0,ind_buffer1);
SetIndexBuffer(1,ind_buffer1s);
SetIndexBuffer(2,ind_buffer2);
SetIndexBuffer(3,ind_buffer2s);
SetIndexBuffer(4,ind_buffer3);
SetIndexBuffer(5,ind_buffer4);
SetIndexBuffer(6, ind_buffer_line_up_flag);
SetIndexBuffer(7, ind_buffer_line_down_flag);
SetIndexBuffer(8,ind_buffer5);
SetIndexBuffer(9,ind_buffer6);
//---- indicator buffers mapping
if(!SetIndexBuffer(0,ind_buffer1) &&
!SetIndexBuffer(1,ind_buffer1s) &&
!SetIndexBuffer(2,ind_buffer2) &&
!SetIndexBuffer(3,ind_buffer2s) &&
!SetIndexBuffer(4,ind_buffer3) &&
!SetIndexBuffer(5,ind_buffer4) &&
!SetIndexBuffer(6, ind_buffer_line_up_flag) &&
!SetIndexBuffer(7, ind_buffer_line_down_flag) &&
!SetIndexBuffer(8,ind_buffer5) &&
!SetIndexBuffer(9,ind_buffer6)
)
Print("cannot set indicator buffers!");
SetIndexArrow(6, 233);
SetIndexArrow(7, 234);
string TimeFrameStr;
switch(TimeFrame)
{
case 1:
TimeFrameStr = "M1";
break;
case 5:
TimeFrameStr = "M5";
break;
case 15:
TimeFrameStr = "M15";
break;
case 30:
TimeFrameStr = "M30";
break;
case 60:
TimeFrameStr = "H1";
break;
case 240:
TimeFrameStr = "H4";
break;
case 1440:
TimeFrameStr = "D1";
break;
case 10080:
TimeFrameStr = "W1";
break;
case 43200:
TimeFrameStr = "MN1";
break;
default:
TimeFrameStr = "CurrTF";
}
//---- name for DataWindow and indicator subwindow label
SetIndexLabel(0,"");
SetIndexLabel(1,"");
SetIndexLabel(2,"");
SetIndexLabel(3,"");
SetIndexLabel(4,"MACD");
SetIndexLabel(5,"SigL");
g_last_alert_datetime = 0;
g_last_bar_changed_alert_datetime = 0;
IndicatorShortName("MACD_OsMA_Jeach_V1.4 ["+TimeFrameStr+"] ("+FastMA_Period+","+SlowMA_Period+","+SignalMA_Period+")");
if (TimeFrame 0)
counted_bars--;
limit= Bars-counted_bars;
limit= MathMax(limit,TimeFrame/Period());
limit= MathMin(limit,MaxBarsToCount);
for(i=0,y=0; i= 0)
{
ind_buffer_line_up_flag[i+1] = ind_buffer3[i+1];// * 0.9;
}
else
{
ind_buffer_line_down_flag[i+1] = ind_buffer3[i+1];// * 1.1;
}
if (!haveEvent)
{
msgTime = Time[i+1];
msg = BuildAlertMessage(Time[i+1], "Signal与MACD线交叉。");
haveEvent = true;
}
}
if ((ind_buffer3[i+1] == 0 || ind_buffer3[i+2]/ind_buffer3[i+1] =0;i--)
for (i=0;iprev)
up=true;
if(current1)
{
if (up != lastDirection)
{
if (g_last_bar_changed_alert_datetime 0)
{
ind_buffer1
=current;
ind_buffer1s
=0.0;
ind_buffer2
=0.0;
ind_buffer2s
=0.0;
}
else
{
ind_buffer1
=0.0;
ind_buffer1s
=current;
ind_buffer2
=0.0;
ind_buffer2s
=0.0;
}
}
else
{
if(current < 0)
{
ind_buffer1
=0.0;
ind_buffer1s
=0.0;
ind_buffer2
=current;
ind_buffer2s
=0.0;
}
else
{
ind_buffer1
=0.0;
ind_buffer1s
=0.0;
ind_buffer2
=0.0;
ind_buffer2s
=current;
}
}
}
for (i=0;i
作者:
349309448
时间:
2018-1-11 14:42
谢谢分享
作者:
349309448
时间:
2018-1-11 15:00
谢谢分享
作者:
90xh
时间:
2018-1-11 16:12
thankyou
作者:
tanke007
时间:
2018-1-11 17:17
谢谢分享
谢谢分享
作者:
昊美广告装饰
时间:
2018-1-11 17:41
法国队好好
作者:
看好了是真的
时间:
2018-1-11 17:55
法国队好好
作者:
mtwspczh
时间:
2018-1-11 18:43
把逻辑判断中的 i+2 替换为 i+1
i+1 替换为 i
但是,这等于在K线未走完时就发出信号,有一定的假信号风险。
作者:
吴强
时间:
2018-1-11 19:51
还行吧 我来赚金币的
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2