//+------------------------------------------------------------------+ //| DayPivotPoint.mq4 | //| Copyright 2019, Roberto Jacobs (3rjfx) | //| https://www.mql5.com/en/users/3rjfx | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, Roberto Jacobs (3rjfx) ~ By 3rjfx ~ Created: 2019/03/20" #property link "https://www.mql5.com/en/users/3rjfx" #property description "Indicator DayPivotPoint System with Signal and Alert for MetaTrader 4" #property description "with options to display signal on the chart." #property description "This Indicator can use only on TF_M1 to H4, and will visually appealing" #property description "only on TF-M5 to TF-H1. Recommendation for Day Trading use on TF-M15." /* Update_01: 2019/03/27 ~ Remove any of bugs and error, and the not used code. */ #property version "1.00" #property strict #property indicator_chart_window //-- enum YN { No, // No Yes // Yes }; //-- enum fonts { Arial_Black, // Arial Black Bodoni_MT_Black // Bodoni MT Black }; //--- //-- input YN alerts = Yes; // Display Alerts / Messages (Yes) or (No) input YN EmailAlert = No; // Email Alert (Yes) or (No) input YN sendnotify = No; // Send Notification (Yes) or (No) input YN displayinfo = Yes; // Display Trade Info input color textcolor = clrSnow; // Text Color input fonts Fonts_Model = Arial_Black; // Choose Fonts Model input color WindColors = clrRed; // Colors for Wingdings input color PvtLColors = clrGold; // Colors for Pivot Lines input ENUM_LINE_STYLE PvtLineStyle = STYLE_SOLID; // Pivot Line style input int PvtLineWidth = 1; // Pivot Line width input int PvtLineShift = 0; // Pivot Line shift input int PvtLineLength = 77; // Pivot Line length //--- //-- int arrpvt=20; int font_siz_=7; color wind_color; string font_ohlc; //-- double Pvt, PvtO, PvtL, PvtH, PvtO1, PvtL1, PvtH1, PvtC1; //-- double pivot[]; string label[]={"S7","S6","S5","S4","S3","S2","SS1","S1","P20","P40","P60","P80","R1","SR1","R2","R3","R4","R5","R6","R7"}; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 //-- ENUM_TIMEFRAMES prsi=PERIOD_M15, prdp=PERIOD_D1; //-- long chart_Id; datetime tla,tlu; datetime thistm, prvtmp, prvtmo; int cur,prv, imnn,imnp, cmnt,pmnt, //lpvt=77, limit; string posisi, sigpos, iname, msgText; string _model; string frtext="PivotLine_"; bool drawpivot, drawpohl; //-- //--- bars minimum for calculation #define DATA_LIMIT 108 //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit(void) { //--- indicators chart_Id=ChartID(); //--- //-- font_ohlc=FontsModel(Fonts_Model); wind_color=WindColors; //--- //-- iname="DayPivotPoint ("+TF2Str(_Period)+")"; IndicatorShortName(iname); IndicatorDigits(Digits); //-- _model=FontsModel(Fonts_Model); drawpivot=false; drawpohl=false; prvtmp=iTime(_Symbol,0,1); prvtmo=iTime(_Symbol,0,1); //-- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //---- Comment(""); string name; for(int i=ObjectsTotal()-1; i>=0; i--) { name=ObjectName(i); if(StringFind(name,frtext,0)>-1) ObjectDelete(0,name); } //-- //GlobalVariablesDeleteAll(); //---- return; } //+------------------------------------------------------------------+ //| 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[]) { //--- Set Last error value to Zero ResetLastError(); RefreshRates(); //-- //--- check for rates total if(rates_total0) limit++; if(limit>=DATA_LIMIT) limit=DATA_LIMIT; ArraySetAsSeries(open,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); ArraySetAsSeries(close,true); ArraySetAsSeries(time,true); //-- tla=time[PvtLineShift]; tlu=time[PvtLineShift+PvtLineLength]; thistm=time[0]; imnn=Minute(); //-- if((!drawpivot)||(thistm!=prvtmp)) DrawPivotPoint(); if((!drawpohl)||(close[0]>PvtH||close[0]=0; i--) { CLOSE[i]=iClose(_Symbol,prsi,i); DPP1[i]= CLOSE[i] - iBands(_Symbol,prsi,20,2.0,0,PRICE_CLOSE,MODE_MAIN,i); DPP2[i]= -(iBearsPower(_Symbol,prsi,13,PRICE_CLOSE,i) + iBullsPower(_Symbol,prsi,13,PRICE_CLOSE,i)); //-- if((DPP1[i]>0)&&(DPP2[i]<0)) DPP3[i]=1.0; else if((DPP1[i]<0)&&(DPP2[i]>0)) DPP3[i]=-1.0; else DPP3[i]=0.0; //-- if(i==0) { iVal0=fabs(DPP1[0])+fabs(DPP2[0]); iVal1=fabs(DPP1[1])+fabs(DPP2[1]); double dif=iVal1*0.38; //-- if(DPP3[i]==1.0 && (iVal0>iVal1+dif)) res=1; else if(DPP3[i]==1.0 && (iVal0iVal1+dif)) res=-1; else if(DPP3[i]==-1.0 && (iVal0