Edit Your Comment
Someone could help me to add alert to this indi pls
Dec 30, 2013 at 11:22
會員從Dec 30, 2013開始
2帖子
Hi, I need to add an alert to this indi, it already has one but even if i activate it, it jut sound each 3-5 minutes even if the arrow doesnt appear in the chart, pls i need to make that the alert sound at the same time that the arrow appear in the chart.
Thanks in advance.
The indicator: https://www.mediafire.com/download/zmjtbwcao9ca355/Arrows.mq4
Thanks in advance.
The indicator: https://www.mediafire.com/download/zmjtbwcao9ca355/Arrows.mq4
Jan 16, 2014 at 20:46
會員從Apr 30, 2011開始
39帖子
here it is what you wished for:
//=========arrows.mq4=====================
#property copyright 'John campbell'
#property link 'https://www.SaneFX.com'
//signal alert added by skaboy 01/16/2014
#define SIGNAL_BAR 1
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Red
double g_ibuf_76[];
double g_ibuf_80[];
double tSignal[];
int g_period_84 = 1;
int g_period_88 = 10;
//extern bool SoundON = FALSE;
extern bool AlertON = FALSE;
double g_time_96;
int init() {
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, g_ibuf_76);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, g_ibuf_80);
SetIndexBuffer(2, tSignal);
return (0);
}
int deinit() {
return (0);
}
int start() {
int li_0;
double ima_4;
double ima_12;
double ima_20;
double ima_28;
double ima_36;
double ima_44;
double ld_52;
double ld_60;
int li_68 = IndicatorCounted();
if (li_68 < 0) return (-1);
if (li_68 > 0) li_68--;
int li_72 = Bars + 1 - li_68;
for (int li_76 = 0; li_76 <= li_72; li_76++) {
li_0 = li_76;
ld_52 = 0;
ld_60 = 0;
for (li_0 = li_76; li_0 <= li_76 + 9; li_0++) ld_60 += MathAbs(High[li_0] - Low[li_0]);
ld_52 = ld_60 / 10.0;
ima_4 = iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_76);
ima_20 = iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_76 + 1);
ima_36 = iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_76 - 1);
ima_12 = iMA(NULL, 0, g_period_88, 0, MODE_EMA, PRICE_CLOSE, li_76);
ima_28 = iMA(NULL, 0, g_period_88, 0, MODE_EMA, PRICE_CLOSE, li_76 + 1);
ima_44 = iMA(NULL, 0, g_period_88, 0, MODE_EMA, PRICE_CLOSE, li_76 - 1);
tSignal[li_76]= 0;
if (ima_4 > ima_12 && ima_20 < ima_28 && ima_36 > ima_44)
{ g_ibuf_76[li_76] = Low[li_76] - ld_52 / 2.0;
tSignal[li_76]= 1;}
else
if (ima_4 < ima_12 && ima_20 > ima_28 && ima_36 < ima_44)
{ g_ibuf_80[li_76] = High[li_76] + ld_52 / 2.0;
tSignal[li_76]= 1;}
/*
if (ima_4 > ima_12 && ima_20 < ima_28 && ima_36 > ima_44) {
g_ibuf_76[li_76] = Low[li_76] - ld_52 / 2.0;
if (SoundON == TRUE && g_time_96 != Time[0]) {
Alert('SaneFxBinary Buy Trade ', Symbol(), Period());
g_time_96 = Time[0];
}
} else {
if (ima_4 < ima_12 && ima_20 > ima_28 && ima_36 < ima_44) {
g_ibuf_80[li_76] = High[li_76] + ld_52 / 2.0;
if (SoundON == TRUE && g_time_96 != Time[0]) {
Alert('SaneFxBinary Sell Trade ', Symbol(), Period());
g_time_96 = Time[0];
}
}
}
*/
}
//----Sound Alert section for MLQ4 article
//---- Static variables where the last bar time
//---- and the last alert direction are stored
static int PrevSignal = 0, PrevTime = 0;
//---- If the bar selected to be analyzed is not a zero bar,
// there is no sense to check the alert
//---- several times. If no new bar starts to be formed, quit.
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime )
return(0);
//---- Mark that this bar was checked
PrevTime = Time[0]; if(PrevSignal <= 0)
{
if(tSignal[SIGNAL_BAR] > 0)
{
PrevSignal = 1;
if (AlertON) Alert('SaneFxBinary Buy Trade ', Symbol(), Period());
}
}
if(PrevSignal >= 0)
{
if(tSignal[SIGNAL_BAR] < 0)
{
PrevSignal = -1;
if (AlertON) Alert('SaneFxBinary Sell Trade ', Symbol(), Period());
}
}
//-- end Alert
return (0);
}
//=================================
Jan 16, 2014 at 20:46
會員從Apr 30, 2011開始
39帖子
oops...sorry for the error
please change this
'''''
tSignal[li_76]= 0;
if (ima_4 > ima_12 && ima_20 < ima_28 && ima_36 > ima_44)
{ g_ibuf_76[li_76] = Low[li_76] - ld_52 / 2.0;
tSignal[li_76]= 1;}
else
if (ima_4 < ima_12 && ima_20 > ima_28 && ima_36 < ima_44)
{ g_ibuf_80[li_76] = High[li_76] + ld_52 / 2.0;
tSignal[li_76]= 1;}
====
to
=====
tSignal[li_76]= 0;
if (ima_4 > ima_12 && ima_20 < ima_28 && ima_36 > ima_44)
{ g_ibuf_76[li_76] = Low[li_76] - ld_52 / 2.0;
tSignal[li_76]= 1;}
else
if (ima_4 < ima_12 && ima_20 > ima_28 && ima_36 < ima_44)
{ g_ibuf_80[li_76] = High[li_76] + ld_52 / 2.0;
tSignal[li_76]= -1;}
========
just copy and paste.
the error is in the sign of tSignal[li_76] in the lst lnie. it should read tSignal[li_76]=-1
ok
please change this
'''''
tSignal[li_76]= 0;
if (ima_4 > ima_12 && ima_20 < ima_28 && ima_36 > ima_44)
{ g_ibuf_76[li_76] = Low[li_76] - ld_52 / 2.0;
tSignal[li_76]= 1;}
else
if (ima_4 < ima_12 && ima_20 > ima_28 && ima_36 < ima_44)
{ g_ibuf_80[li_76] = High[li_76] + ld_52 / 2.0;
tSignal[li_76]= 1;}
====
to
=====
tSignal[li_76]= 0;
if (ima_4 > ima_12 && ima_20 < ima_28 && ima_36 > ima_44)
{ g_ibuf_76[li_76] = Low[li_76] - ld_52 / 2.0;
tSignal[li_76]= 1;}
else
if (ima_4 < ima_12 && ima_20 > ima_28 && ima_36 < ima_44)
{ g_ibuf_80[li_76] = High[li_76] + ld_52 / 2.0;
tSignal[li_76]= -1;}
========
just copy and paste.
the error is in the sign of tSignal[li_76] in the lst lnie. it should read tSignal[li_76]=-1
ok
*商業用途和垃圾郵件將不被容忍,並可能導致帳戶終止。
提示:發佈圖片/YouTube網址會自動嵌入到您的帖子中!
提示:鍵入@符號,自動完成參與此討論的用戶名。