//+------------------------------------------------------------------+ //| MTF signal.mq4 | //| Sehat | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Sehat" #property link "http://www.metaquotes.net" #property indicator_chart_window extern bool _email = false; extern bool _alert = true; extern bool _5 = true; extern bool _15 = true; extern bool _30 = false; extern bool _60 = true; extern bool _240 = false; extern bool _1440 = false; double trix5=0; double trix15=0; double trix30=0; double trix60=0; double trix240=0; double trix1440=0; int trix5up = 0; int trix15up = 0; int trix30up = 0; int trix60up = 0; int trix240up = 0; int trix1440up = 0; string comment=""; bool alerted = NULL; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); string sSubject=""; string sText=""; comment = ""; // Added by Robert if (_5) comment = "5"; if (_15) comment = comment + ",15"; if (_30) comment = comment + ",30"; if (_60) comment = comment + ",60"; if (_240) comment = comment + ",240"; if (_1440) comment = comment + ",1440"; comment = comment + ":"; //---- //Get the trix value for each timeframe and also calculate direction //We use the if to minimize cpu load i.e. do not need to count what is not enabled if (_5) { trix5 = iCustom(NULL,5,"smSuper TRIX_v1",3,"averages",1,1,1,"input_price",0,"Signals",true,false,false,500,0,1); if (trix5 > 0) trix5up=1; else trix5up=-1; } else _5 = 0; if (_15) { trix15 = iCustom(NULL,15,"smSuper TRIX_v1",3,"averages",1,1,1,"input_price",0,"Signals",true,false,false,500,0,1); if (trix15 > 0) trix15up=1; else trix15up=-1; } else _15 = 0; if (_30) { trix30 = iCustom(NULL,30,"smSuper TRIX_v1",3,"averages",1,1,1,"input_price",0,"Signals",true,false,false,500,0,1); if (trix30 > 0) trix30up=1; else trix30up=-1; } else _30 = 0; if (_60) { trix60 = iCustom(NULL,60,"smSuper TRIX_v1",3,"averages",1,1,1,"input_price",0,"Signals",true,false,false,500,0,1); if (trix60 > 0) trix60up=1; else trix60up=-1; } else _60 = 0; if (_240) { trix240 = iCustom(NULL,240,"smSuper TRIX_v1",3,"averages",1,1,1,"input_price",0,"Signals",true,false,false,500,0,1); if (trix240 > 0) trix240up=1; else trix240up=-1; } else _240 = 0; if (_1440) { trix1440 = iCustom(NULL,1440,"smSuper TRIX_v1",3,"averages",1,1,1,"input_price",0,"Signals",true,false,false,500,0,1); if (trix1440 > 0) trix1440up=1; else trix1440up=-1; } else _1440 = 0; //ACTION START HERE //Up signal is out bool buy = true; if (_5 && trix5up!=1 ) buy = false; // Checks for failure if (buy && _15 && trix15up!=1) buy = false; if (buy && _30 && trix30up!=1) buy = false; if (buy && _60 && trix60up!=1) buy = false; if (buy && _240 && trix240up!=1) buy = false; if (buy && _1440 && trix1440up!=1) buy = false; if (buy) { if (!alerted) { sSubject = comment + " Buy for " + Symbol(); alerted = true; if (_alert) Alert(comment + " Buy for " + Symbol()); if (_email) SendMail(sSubject,sText); } } //Down signal is out bool sell = true; if (_5 && trix5up!=-1) sell = false; // Checks for failure if (sell && _15 && trix15up!=-1) sell = false; if (sell && _30 && trix30up!=-1) sell = false; if (sell && _60 && trix60up!=-1) sell = false; if (sell && _240 && trix240up!=-1) sell = false; if (sell && _1440 && trix1440up!=-1) sell = false; if (sell) { if (!alerted) { sSubject = comment + " Sell for " + Symbol(); alerted = true; if (_alert) Alert(comment + " Sell for " + Symbol()); if (_email) SendMail(sSubject,sText); } } //No signal else { alerted = false; } //visual Comment(comment); //---- return(0); } //+------------------------------------------------------------------+