This forum is now read-only. You can discuss you questions on Forums of MQL4.community and MQL5.community
Script helpBack to topics list |
|
Palmer
2007.05.25 18:03
The following script is 'supposed' to do as follows:
On the 4hr EURUSD chart: The conditions for a bull trend re-entry: When the bid > 89sma && the 8ema > 21ema && the difference between the 8ema and 21 ema > 0.0002 && the bid < the 14ema (opposite for a bear trend re-entry) I'm supposed to get en email alert sent to me and have an audible alarm sound. I've watched the price meet all the conditions but the script doesn't function. The loop is in there to continuously check to make sure the script keeps running until the conditions are met. I have this running on a few different charts and the script is named differently per chart. I can't figure this one out... Any help would be much appreciated.
//+------------------------------------------------------------------+
//| TCSCRIPTALERTv1.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double Near = iMA(NULL,0,14,0,MODE_EMA,PRICE_CLOSE,0);
double PriceNow = Bid;
double Trend = iMA(NULL,0,89,0,MODE_SMA,PRICE_CLOSE,0);
double fast = iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,0);
double slow = iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE,0);
double bullspread = (fast - slow);
double bearspread = (slow - fast);
// Delete previous screen text
ObjectDelete("script is running");
ObjectDelete("comment_label");
ObjectDelete("reload");
// Script running text
ObjectCreate("script is running",OBJ_LABEL,0,0,0);
ObjectSet("script is running",OBJPROP_XDISTANCE,0);
ObjectSet("script is running",OBJPROP_YDISTANCE,15);
ObjectSetText("script is running","TC SCRIPT ALERT ON",15,"Arial",Yellow);
bool not_done = true;
while(not_done)
{
// Conditions for BULL TC alert
if ((PriceNow > Trend) && (fast > slow) && (bullspread > 0.0002) && (PriceNow < Near))
{
//Alerts
SendMail("From Chris Palmer - Data","BULL TC ALERT ON THE EUR-USD!!!");
not_done=false;
Alert(Symbol() , " BULL ","TC ALERT!");
Sleep(500);
PlaySound("sirenhilo.wav");
ObjectCreate("comment_label",OBJ_LABEL,0,0,0);
ObjectSet("comment_label",OBJPROP_XDISTANCE,0);
ObjectSet("comment_label",OBJPROP_YDISTANCE,35);
ObjectSetText("comment_label","BULL TC ALERT!",15,"Arial",Lime);
ObjectCreate("reload",OBJ_LABEL,0,0,0);
ObjectSet("reload",OBJPROP_XDISTANCE,0);
ObjectSet("reload",OBJPROP_YDISTANCE,55);
ObjectSetText("reload","RELOAD SCRIPT",15,"Arial",Blue);
}
// If BEAR TC alert
else if ((PriceNow < Trend) && (fast < slow) && (bearspread > 0.0002) && (PriceNow > Near))
{
SendMail("From Chris Palmer - Data","BEAR TC ALERT ON THE EUR-USD!!!");
not_done=false;
Alert(Symbol() , " BEAR ","TC ALERT!");
Sleep(500);
PlaySound("sirenhilo.wav");
ObjectCreate("comment_label",OBJ_LABEL,0,0,0);
ObjectSet("comment_label",OBJPROP_XDISTANCE,0);
ObjectSet("comment_label",OBJPROP_YDISTANCE,35);
ObjectSetText("comment_label","BEAR TC ALERT!",15,"Arial",Red);
ObjectCreate("reload",OBJ_LABEL,0,0,0);
ObjectSet("reload",OBJPROP_XDISTANCE,0);
ObjectSet("reload",OBJPROP_YDISTANCE,55);
ObjectSetText("reload","RELOAD SCRIPT",15,"Arial",Blue);
}
Sleep(1000);
}
return(0);
}
|
3289 |
Rosh
2007.05.25 18:29
You compulsorily must use function RefreshRates() in endless looped cycle - "MQL4: RefreshRates" And don't forget move callings of custom indicators into cycle too.
Read a little themes according to the results of this search - http://docs.mql4.com/search/RefreshRates |
|
Palmer
2007.05.27 02:42
The only place I can think to put that is after the beginning of the loop at
bool not_done = true; while(not_done) Refreshrates(); ??? |
