//+------------------------------------------------------------------+ //| PopupAlert.mq4 | //| Benjam | //| | //+------------------------------------------------------------------+ #property copyright "Benjam" #property link "" #property version "2.10" #property strict #property indicator_chart_window bool extern RSI_OnOff = true; bool extern STOC_OnOff = true; bool extern BOLI_OnOff = true; string extern alert = "";// ========================================= bool extern Alert_OnOff = true; bool extern Alert_Sound = true; int RSI_SWITCH, STOC_SWITCH, BOLI_SWITCH; int RSI_ORD, STOC_ORD, BOLI_ORD; static datetime tmp; int TTF = Period(); string timep,Sym = Symbol(); int wait_TF = 0; bool firsttick; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping Comment("PopUp Alerting - "+Symbol()+" - "+DoubleToStr(Period(),0)+" TF"); tmp = Time[0]; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate (const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[]) { //------------------- EXPIRY ------------------ /* datetime EXP = D'2014.09.01 00:00'; if(TimeCurrent() < EXP) { */ //------------------- EXPIRY ------------------ //---------------------------------------------------------------- double BOLI_Price_UP = iBands(NULL,PERIOD_M1,20,2,0,PRICE_CLOSE,MODE_UPPER,1); double BOLI_Price_DOWN = iBands(NULL,PERIOD_M1,20,2,0,PRICE_CLOSE,MODE_LOWER,1); double BOLI_Price_MID = iBands (NULL,PERIOD_M1,20,2,0,PRICE_CLOSE,MODE_MAIN,1); double Last_Price = iClose(NULL,PERIOD_M1,1); double Last_Price2 = iClose(NULL,PERIOD_M1,2); double EMA10_5 = iMA(NULL,PERIOD_M5,10,0,MODE_EMA,PRICE_CLOSE,0); double EMA15_5 = iMA(NULL,PERIOD_M5,15,0,MODE_EMA,PRICE_CLOSE,0); double EMA10_15 = iMA(NULL,PERIOD_M15,10,0,MODE_EMA,PRICE_CLOSE,0); double EMA15_15 = iMA(NULL,PERIOD_M15,15,0,MODE_EMA,PRICE_CLOSE,0); double EMA10_30 = iMA(NULL,PERIOD_M30,10,0,MODE_EMA,PRICE_CLOSE,0); double EMA15_30 = iMA(NULL,PERIOD_M30,15,0,MODE_EMA,PRICE_CLOSE,0); double EMA10_51 = iMA(NULL,PERIOD_M5,10,0,MODE_EMA,PRICE_CLOSE,1); double EMA15_51 = iMA(NULL,PERIOD_M5,15,0,MODE_EMA,PRICE_CLOSE,1); double EMA10_52 = iMA(NULL,PERIOD_M5,10,0,MODE_EMA,PRICE_CLOSE,2); double EMA15_52 = iMA(NULL,PERIOD_M5,15,0,MODE_EMA,PRICE_CLOSE,2); double EMA10_151 = iMA(NULL,PERIOD_M15,10,0,MODE_EMA,PRICE_CLOSE,1); double EMA15_151 = iMA(NULL,PERIOD_M15,15,0,MODE_EMA,PRICE_CLOSE,1); double EMA10_152 = iMA(NULL,PERIOD_M15,10,0,MODE_EMA,PRICE_CLOSE,2); double EMA15_152 = iMA(NULL,PERIOD_M15,15,0,MODE_EMA,PRICE_CLOSE,2); double EMA10_301 = iMA(NULL,PERIOD_M30,10,0,MODE_EMA,PRICE_CLOSE,1); double EMA15_301 = iMA(NULL,PERIOD_M30,15,0,MODE_EMA,PRICE_CLOSE,1); double EMA10_302 = iMA(NULL,PERIOD_M30,10,0,MODE_EMA,PRICE_CLOSE,2); double EMA15_302 = iMA(NULL,PERIOD_M30,15,0,MODE_EMA,PRICE_CLOSE,2); //---------------------------------------------------------------- if(TTF != Period() || Sym!=Symbol()) { Sym = Symbol(); TTF = Period(); Reset(); } //---------------------------------------------------------------- if(firsttick == true) if( (Last_Price > BOLI_Price_UP) && (EMA15_5 > EMA10_5) && (EMA15_51 < EMA15_52) && (EMA10_51 < EMA10_52) && (EMA15_5 < EMA15_51) && (EMA10_5 < EMA10_51) ) { //---------------------------------------------------------------- if(Alert_OnOff == true) timep = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES); Alert (Symbol() + " SELL! TREND 5 mins" "\n" "Expiry - 5 Mins" "\n" "Time - "+timep +"\n" "Price - "+DoubleToStr(Bid,4) ); if(Alert_Sound==true) { PlaySound("Alert.wav"); } //---------------------------------------------------------------- Reset(); wait_TF = 1; } if(firsttick == true) if( (Last_Price < BOLI_Price_DOWN) && (EMA10_5 > EMA15_5) && (EMA15_51 > EMA15_52) && (EMA10_51 > EMA10_52) && (EMA15_5 > EMA15_51) && (EMA10_5 > EMA10_51) ) { //---------------------------------------------------------------- if(Alert_OnOff == true) { timep = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES); Alert (Symbol() + " BUY! TREND 5 mins" "\n" "Expiry - 5 Mins" "\n" "Time - "+timep +"\n" "Price - "+DoubleToStr(Bid,4) ); if(Alert_Sound==true) { PlaySound("Alert.wav"); } } //---------------------------------------------------------------- Reset(); wait_TF = 1; } //---------------------------------------------------------------- /* Print("The RSI is above 70 or below 30 === "+RSI_SWITCH+" === RSI came back from 70 or 30 === "+RSI_ORD); Print("The STOC is above 80 or 20 === "+STOC_SWITCH+" === STOC came back from 80 or 20 === "+STOC_ORD); Print("Pricwe is over uper or lower BOLI === "+BOLI_SWITCH+" === Price came back inside BOLI === "+BOLI_ORD); Print("=== Tick ==="); Print ("POPUP trigerd in this bar - "+wait_TF); */ // //--- firsttick = false; if (tmp!= Time[0]) { tmp = Time[0]; wait_TF = 0; firsttick = true; } //--- return value of prev_calculated for next call //------------------- EXPIRY ------------------ /* } else { Comment("Indicator time is EXPIRY! "); Alert("Indicator time is EXPIRY!!!"); } */ //------------------- EXPIRY ------------------ return(rates_total); } //+---------------------------- End Of OnCalculate--------------------------------------+ void Reset() { }