一个指标报警的问题,请高手给予指教!
想给这个指标增加报警功能,但是在两线粘连的情况下无法正常报警,出现多空同时报警且不能发出声音的情况,请高手给予修改并指教。 要求在两线交叉后的第二根K线时发出报警声音,如果可能的话控制报警次数为5次并发送1次邮件报警。 #property copyright "Copyright ?2006, Hu." #property link "" #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Red #property indicator_color2 Green #property indicator_color3 Blue #property indicator_color4 Salmon #property indicator_color5 Yellow #property indicator_color6 White #property indicator_level1 0 #property indicator_level2 10000 extern bool bTrend = FALSE; double g_ibuf_80[]; double g_ibuf_84[]; double g_ibuf_88[]; double g_ibuf_92[]; double g_ibuf_96[]; double g_ibuf_10000[]; extern int EMA_Period1 = 9; extern int EMA_Period2 = 3; extern int EMA_Period3 = 30; extern int EMA_Period4 = 5; extern int SMA_Period1 = 34; extern int SMA_Period2 = 89; extern int LH_Period1 = 34; extern int LH_Period2 = 89; extern int LH_Period3 = 250; extern bool alert_folkupb = FALSE; extern bool alert_folkdwb = FALSE; int gi_114 = 0; int gi_118 = 0; int init() { SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, g_ibuf_80); SetIndexLabel(0, "BDC"); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(1, g_ibuf_84); SetIndexLabel(1, "BDD"); SetIndexStyle(2, DRAW_LINE); SetIndexBuffer(2, g_ibuf_88); SetIndexLabel(2, "BDE"); SetIndexStyle(3, DRAW_LINE); SetIndexBuffer(3, g_ibuf_92); SetIndexLabel(3, "BDF"); SetIndexStyle(4, DRAW_LINE); SetIndexBuffer(4, g_ibuf_96); SetIndexLabel(4, "中期趋势"); SetIndexStyle(5, DRAW_LINE); SetIndexBuffer(5, g_ibuf_10000); SetIndexLabel(5, "长期趋势"); IndicatorShortName("BDQS BDC: BDD: BDE: BDF:" + "中期趋势:kw" + "长期趋势:km" + "风险区:80," + "安全区:20"); return (0); } int deinit() { return (0); } int start() { int l_count_12; double ld_20; double l_low_28; double l_high_36; double ld_92; double ld_10000; double ld_unused_108; int li_0 = IndicatorCounted(); if (li_0 < 0) return (-1); if (li_0 > 0) li_0--; int li_4 = Bars - li_0; double ld_116 = 2.0 / (EMA_Period1 + 1); double ld_124 = 2.0 / (EMA_Period2 + 1); double ld_132 = 2.0 / (EMA_Period3 + 1); double ld_140 = 2.0 / (EMA_Period4 + 1); for (int li_8 = li_4; li_8 >= 0; li_8--) { ld_10000 = 0; ld_unused_108 = 0; ld_20 = (2.0 * Close[li_8] + High[li_8] + Low[li_8]) / 4.0; l_low_28 = Low[iLowest(NULL, 0, MODE_LOW, LH_Period1, li_8)]; l_high_36 = High[iHighest(NULL, 0, MODE_HIGH, LH_Period1, li_8)]; if (l_high_36 - l_low_28 == 0.0) ld_92 = 0; else ld_92 = 10000.0 * ((ld_20 - l_low_28) / (l_high_36 - l_low_28)); if (li_8 == Bars - 2) { ld_20 = (2.0 * (Close[li_8 + 1]) + (High[li_8 + 1]) + (Low[li_8 + 1])) / 4.0; l_low_28 = Low[li_8 + 1]; l_high_36 = High[li_8 + 1]; if (l_high_36 - l_low_28 == 0.0) ld_92 = 0; else ld_92 = 10000.0 * ((ld_20 - l_low_28) / (l_high_36 - l_low_28)); g_ibuf_80[li_8] = ld_92; g_ibuf_88[li_8] = ld_92; g_ibuf_84[li_8] = g_ibuf_80[li_8]; g_ibuf_92[li_8] = ld_92; } else { g_ibuf_80[li_8] = ld_92 * ld_116 + (g_ibuf_80[li_8 + 1]) * (1 - ld_116); g_ibuf_88[li_8] = ld_92 * ld_132 + (g_ibuf_88[li_8 + 1]) * (1 - ld_132); ld_92 = 0.667 * (g_ibuf_80[li_8 + 1]) + 0.333 * g_ibuf_80[li_8]; g_ibuf_84[li_8] = ld_92 * ld_124 + (g_ibuf_84[li_8 + 1]) * (1 - ld_124); g_ibuf_92[li_8] = g_ibuf_88[li_8] * ld_140 + (g_ibuf_92[li_8 + 1]) * (1 - ld_140); } if (bTrend == TRUE) { ld_20 = Close[li_8]; l_low_28 = Low[iLowest(NULL, 0, MODE_LOW, LH_Period2, li_8)]; l_high_36 = High[iHighest(NULL, 0, MODE_HIGH, LH_Period2, li_8)]; if (l_high_36 - l_low_28 == 0.0) ld_92 = 0; else ld_92 = 10000.0 * ((ld_20 - l_low_28) / (l_high_36 - l_low_28)); if (li_8 >= Bars - SMA_Period1) { l_count_12 = 0; for (int li_16 = li_8; l_count_12 < SMA_Period1; li_16++) { ld_20 = Close[li_16]; l_low_28 = Low[iLowest(NULL, 0, MODE_LOW, LH_Period2, li_16)]; l_high_36 = High[iHighest(NULL, 0, MODE_HIGH, LH_Period2, li_16)]; if (l_high_36 - l_low_28 == 0.0) ld_92 = 0; else ld_92 = 10000.0 * ((ld_20 - l_low_28) / (l_high_36 - l_low_28)); ld_10000 += ld_92; g_ibuf_96[li_16] = 0; l_count_12++; } } else ld_10000 = (g_ibuf_96[li_8 + 1]) * (SMA_Period1 - 1) + ld_92; g_ibuf_96[li_8] = ld_10000 / SMA_Period1; ld_20 = Close[li_8]; l_low_28 = Low[iLowest(NULL, 0, MODE_LOW, LH_Period3, li_8)]; l_high_36 = High[iHighest(NULL, 0, MODE_HIGH, LH_Period3, li_8)]; if (l_high_36 - l_low_28 == 0.0) ld_92 = 0; else ld_92 = 10000.0 * ((ld_20 - l_low_28) / (l_high_36 - l_low_28)); if (li_8 >= Bars - SMA_Period2) { l_count_12 = 0; for (li_16 = li_8; l_count_12 < SMA_Period2; li_16++) { ld_20 = Close[li_16]; l_low_28 = Low[iLowest(NULL, 0, MODE_LOW, LH_Period3, li_16)]; l_high_36 = High[iHighest(NULL, 0, MODE_HIGH, LH_Period3, li_16)]; if (l_high_36 - l_low_28 == 0.0) ld_92 = 0; else ld_92 = 10000.0 * ((ld_20 - l_low_28) / (l_high_36 - l_low_28)); ld_10000 += ld_92; g_ibuf_10000[li_16] = 0; l_count_12++; } } else ld_10000 = (g_ibuf_10000[li_8 + 1]) * (SMA_Period2 - 1) + ld_92; g_ibuf_10000[li_8] = ld_10000 / SMA_Period2; } if (g_ibuf_80[li_8+3] < g_ibuf_84[li_8+3] && g_ibuf_80[li_8+2] > g_ibuf_84[li_8+2] && g_ibuf_80[li_8+1] > g_ibuf_84[li_8+1] && gi_114 != 1 && alert_folkdwb == TRUE) { alert("[" + Symbol() + "][" + Period() + "分钟]zt:BDQ发生金叉!"); gi_114 = 1; } if (g_ibuf_80[li_8+3] > g_ibuf_84[li_8+3] && g_ibuf_80[li_8+2] < g_ibuf_84[li_8+2] && g_ibuf_80[li_8+1] < g_ibuf_84[li_8+1] && gi_114 != 2 && alert_folkupb == TRUE ) { alert("[" + Symbol() + "][" + Period() + "分钟]zt:BDQ发生死叉!"); gi_114 = 2; } } return (0); } |
打赏
最新创建圈子
- 新闻EA运行效果图圈 2019-05-05
圈主:admin 帖子:1