static datetime alert.allowed; if (CONDITION && CurTime() >= alert.allowed) { alert.allowed = Time[0] + Period(); // No more alerts this bar //alert.allowed = CurTime() + 5*60; // No more alerts for 5 minutes alert(...); }
Anyone can assist? it keeps alerting everytime it touches the EMA
Allow move than 2 hours for someone to reply, jeese!
Thanks and sorry about the quick bump up.
P.S.
Where do I place this at? :)
I tried this but got this error:
'CONDITION' - variable not defined C:\Program Files\MetaTrader 4 at FOREX.com - Copy\experts\indicators\###365EMA Price Crosses MA (Alert).mq4 (99, 5)
//+------------------------------------------------------------------+
//| MA Cross Arrows.mq4 |
//| Copyright © 2006 Scorpion@fxfisherman.com |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link "http://www.fxfisherman.com"
//Crossed_Pips: If you want to delay until price has crossed x pips from MA, set it to x. Set to 0 for instant alert.
//MA_Type: Moving Average Type. 0 = Simple, 1 = Exponential, 2 = Smooth, 3 = Weighted
//MA_Period: Moving Average Period (bars).
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Wheat
#property indicator_color2 White
#property indicator_color3 DarkTurquoise
extern int Crossed_Pips = 0;
extern int MA_Period = 365;
extern int MA_Type = 1;
extern int Shift_Bars=0;
extern int Bars_Count= 1000;
int state;
//---- buffers
double v1[];
double v2[];
double v3[];
int init()
{
IndicatorBuffers(3);
SetIndexArrow(0,217);
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
SetIndexDrawBegin(1,MA_Period * 2);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Buy");
SetIndexArrow(1,218);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
SetIndexDrawBegin(1,MA_Period * 2);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"Sell");
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
SetIndexDrawBegin(1,MA_Period * 2);
SetIndexBuffer(2, v3);
SetIndexLabel(2,"MA");
watermark();
return(0);
}
int start()
{
double ma;
int previous;
int i;
int shift;
bool crossed_up, crossed_down;
int totalBars = Bars - (MA_Period * 2);
if (Bars_Count > 0 && Bars_Count <= totalBars)
{
i = Bars_Count;
}else if(totalBars <= 0 ) {
return(0);
}else{
i = totalBars;
}
while(i>=0)
{
shift = i + Shift_Bars;
ma = iMA(Symbol(), Period(), MA_Period, 0, MA_Type, PRICE_CLOSE, shift);
crossed_up = High[shift] >= (ma + (Crossed_Pips * Point));
crossed_down = Low[shift] <= (ma - (Crossed_Pips * Point));
v1[i] = NULL;
v2[i] = NULL;
v3[i] = ma;
if (crossed_up && previous != 1) {
v1[i] = ma + (Crossed_Pips * Point);
previous = 1;
}else if(crossed_down && previous != 2){
v2[i] = ma - (Crossed_Pips * Point);
previous = 2;
}
i--;
}
static datetime alert.allowed;
if (CONDITION && CurTime() >= alert.allowed) {
alert.allowed = Time[0] + Period(); // No more alerts this bar
//alert.allowed = CurTime() + 5*60; // No more alerts for 5 minutes
alert(...);
}
ma = iMA(Symbol(), Period(), MA_Period, 0, MA_Type, PRICE_CLOSE, 0);
if (Close[0] >= ma + (Crossed_Pips * Point) && state != 1) {
state = 1;
Alert("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2));
SendMail("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2),"H: " + iHigh(NULL, 0, 0) + " L: " + iLow(NULL, 0, 0) + " C: " + iClose(NULL, 0, 0));
}else if (Close[0] <= ma - (Crossed_Pips * Point) && state != -1) {
state = -1;
Alert("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2));
SendMail("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2),"H: " + iHigh(NULL, 0, 0) + " L: " + iLow(NULL, 0, 0) + " C: " + iClose(NULL, 0, 0));
}
return(0);
}
//+------------------------------------------------------------------+
void watermark()
{
ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue);
ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
return(0);
}
Anyone knows how to add that code in correctly? Really no coding knowledge.
Thank you
I guess you just want us to give you a prod when the money starts rolling into your bank account?
Why not have a wee look at the docs?
You'll get more help on here if you get up off your backside and put in some effort - rather than just expecting everything to be done for you.
CB
I tried this but got this error:
'CONDITION' - variable not defined C:\Program Files\MetaTrader 4 at FOREX.com - Copy\experts\indicators\###365EMA Price Crosses MA (Alert).mq4 (99, 5)
if (CONDITION && CurTime() >= alert.allowed) { alert.allowed = Time[0] + Period(); // No more alerts this bar //alert.allowed = CurTime() + 5*60; // No more alerts for 5 minutes alert(...);You have:
if (Close[0] >= ma + (Crossed_Pips * Point) && state != 1) { state = 1; Alert("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2));Therefor CONDITION is
Close[0] >= ma + (Crossed_Pips * Point) && state != 1
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
//| MA Cross Arrows.mq4 |
//| Copyright © 2006 Scorpion@fxfisherman.com |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link "http://www.fxfisherman.com"
//Crossed_Pips: If you want to delay until price has crossed x pips from MA, set it to x. Set to 0 for instant alert.
//MA_Type: Moving Average Type. 0 = Simple, 1 = Exponential, 2 = Smooth, 3 = Weighted
//MA_Period: Moving Average Period (bars).
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Wheat
#property indicator_color2 White
#property indicator_color3 DarkTurquoise
extern int Crossed_Pips = 0;
extern int MA_Period = 365;
extern int MA_Type = 1;
extern int Shift_Bars=0;
extern int Bars_Count= 1000;
int state;
//---- buffers
double v1[];
double v2[];
double v3[];
int init()
{
IndicatorBuffers(3);
SetIndexArrow(0,217);
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
SetIndexDrawBegin(1,MA_Period * 2);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Buy");
SetIndexArrow(1,218);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
SetIndexDrawBegin(1,MA_Period * 2);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"Sell");
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
SetIndexDrawBegin(1,MA_Period * 2);
SetIndexBuffer(2, v3);
SetIndexLabel(2,"MA");
watermark();
return(0);
}
int start()
{
double ma;
int previous;
int i;
int shift;
bool crossed_up, crossed_down;
int totalBars = Bars - (MA_Period * 2);
if (Bars_Count > 0 && Bars_Count <= totalBars)
{
i = Bars_Count;
}else if(totalBars <= 0 ) {
return(0);
}else{
i = totalBars;
}
while(i>=0)
{
shift = i + Shift_Bars;
ma = iMA(Symbol(), Period(), MA_Period, 0, MA_Type, PRICE_CLOSE, shift);
crossed_up = High[shift] >= (ma + (Crossed_Pips * Point));
crossed_down = Low[shift] <= (ma - (Crossed_Pips * Point));
v1[i] = NULL;
v2[i] = NULL;
v3[i] = ma;
if (crossed_up && previous != 1) {
v1[i] = ma + (Crossed_Pips * Point);
previous = 1;
}else if(crossed_down && previous != 2){
v2[i] = ma - (Crossed_Pips * Point);
previous = 2;
}
i--;
}
ma = iMA(Symbol(), Period(), MA_Period, 0, MA_Type, PRICE_CLOSE, 0);
if (Close[0] >= ma + (Crossed_Pips * Point) && state != 1) {
state = 1;
Alert("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2));
SendMail("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2),"H: " + iHigh(NULL, 0, 0) + " L: " + iLow(NULL, 0, 0) + " C: " + iClose(NULL, 0, 0));
}else if (Close[0] <= ma - (Crossed_Pips * Point) && state != -1) {
state = -1;
Alert("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2));
SendMail("365EMA Touched " + Symbol() + " TF " + Period() + " Date " + TimeToStr(iTime(NULL, 0, 0) | 2),"H: " + iHigh(NULL, 0, 0) + " L: " + iLow(NULL, 0, 0) + " C: " + iClose(NULL, 0, 0));
}
return(0);
}
//+------------------------------------------------------------------+
void watermark()
{
ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue);
ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
return(0);
}