//+------------------------------------------------------------------+ //| FXX_Ichi.mq4 | //| GumRai | //| none | //+------------------------------------------------------------------+ #property copyright "GumRai" #property link "none" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 3 //--- input parameters input int Tenkan_Period=9; input color UpArrowColour=clrDodgerBlue; input color DownArrowColour=clrRed; input int ArrowSize=3; input bool ShowTenkan=true; //Show Tenkan Line input int Line_Width=1; //Width of Tenkan Line (1 to 5) input color Line_Col=clrDodgerBlue; //Colour of Tenkan Line input bool EnablePopUp=true; //Enable Pop-Up Alert input bool Send_Email=false; //Send Email Alert input bool Send_Push=false; //Send Push Notification Alert int ZeroBars; string Signal; datetime LastAlertBarTime=0; string MessageText; double Offset; double Tenkan_Buffer[]; double Tenkan_Up[]; double Tenkan_Down[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping if(ShowTenkan) SetIndexStyle(0,DRAW_LINE,EMPTY,Line_Width,Line_Col); else SetIndexStyle(0,DRAW_NONE); SetIndexBuffer(0,Tenkan_Buffer); SetIndexDrawBegin(0,Tenkan_Period-1); SetIndexLabel(0,"Tenkan Sen"); IndicatorSetInteger(INDICATOR_DIGITS,Digits); SetIndexBuffer(1,Tenkan_Up); SetIndexStyle(1,DRAW_ARROW,EMPTY,ArrowSize,UpArrowColour); SetIndexArrow(1,241); SetIndexBuffer(2,Tenkan_Down); SetIndexStyle(2,DRAW_ARROW,EMPTY,ArrowSize,DownArrowColour); SetIndexArrow(2,242); Offset=(ChartGetDouble(0,CHART_PRICE_MAX)-ChartGetDouble(0,CHART_PRICE_MIN))/15; ZeroBars=Tenkan_Period+1; string tf; switch(Period()) { case 1:tf="1 Minute Timeframe. "; break; case 5:tf="5 Minute Timeframe. "; break; case 15:tf="15 Minute Timeframe. "; break; case 30:tf="30 Minute Timeframe. "; break; case 60:tf="Hourly Timeframe. "; break; case 240:tf="4 Hour Timeframe. "; break; case 1440:tf="Daily Timeframe. "; break; case 10080:tf="Weekly Timeframe. "; break; case 43200:tf="Monthly Timeframe. "; break; default:tf="Chart. ";break; } MessageText=Symbol()+". "+tf; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| 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[]) { //--- int limit=rates_total-prev_calculated+1; if(prev_calculated==0) limit=rates_total-ZeroBars; double tenkan,h,l,price; int k; for(int index=limit;index>0;index--) { h=High[index]; l=Low[index]; k=index-1+Tenkan_Period; while(k>=index) { price=High[k]; if(hprice) l=price; k--; } tenkan=(h+l)/2; Tenkan_Buffer[index]=tenkan; if(Close[index]>tenkan && Signal!="Buy") { Signal="Buy"; //Tenkan_Up[index]=Low[index]-(Period()*Point); Tenkan_Up[index]=Low[index]-Offset; if(index==1) if(prev_calculated!=0) SendAlerts("Price closed above Tenkan"); } if(Close[index]LastAlertBarTime) { LastAlertBarTime=Time[0]; string message=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+", "+MessageText+t; if(EnablePopUp) { Alert(MessageText+t); Print(message); } if(Send_Email) SendMail("MT4 Alert, Tenkan",message); if(Send_Push) SendNotification(message); } }