//+------------------------------------------------------------------+ //| wfx_MySR_Levels_V1.mq4 | //| Girard Matthieu | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Girard Matthieu" #property link "https://www.mql5.com" #property version "1.07" #property script_show_inputs #property indicator_chart_window #property strict extern string LineHorizontal="A"; //Key to Create a SR Line (1) extern color LineResistcolor=clrDodgerBlue; //Resistance Line Color (1) extern color LineSupportcolor=clrDarkOrange; //Support Line Color (1) extern ENUM_LINE_STYLE LineStyle=STYLE_SOLID; //Style of SR Lines (1) extern int Linewidth=1; //Choose the width of the line (1) extern string LineHorizontalSecond="Q"; //Key to Create a SR Line (2) extern color LineResistcolorSecond=clrDodgerBlue; //Resistance Line Color (2) extern color LineSupportcolorSecond=clrDarkOrange; //Support Line Color (2) extern ENUM_LINE_STYLE LineStyleSecond=STYLE_DOT; //Style of SR Lines (2) extern int LinewidthSecond=1; //Choose the width of the line (2) extern bool TakecareManualTrendline=true; //Take care of your Trendline added manually extern string DeleteLastLine="X"; //Key to Delete Last SR Line extern bool AlarmCrossWhithAlert=true; //Send an Alert extern bool AlarmCrossWhithPushSmartphone=false; //Send a Notification extern bool MagnetLinePriceOnFullPip = true; //To make a line at 1.1500 even if the mouse is at 1.15002 extern double DefaultLotSize=0.1; //Lot Size to Calc Money Values extern int history=200; //Number of candles to check, could be 200 minutes or 200 weeks depending on your timeframe extern int MaxDeviation=10; //If the candle stops at less than 10 pips it will appear in the history of support and resistance extern color Textcolor=clrRed; //Color of mouse position and history extern bool Commentornot=true; //You can choose to see mouse and history of support/resistance in the comment or in positionable label int xmouse; //the x coordinate of the mouse int ymouse; //the y coordinate of the mouse string LineId=""; //the name line double price =0; //keep the mouse price int minus; double pips; string linehistory=""; int x=50; // axe x start int y=130; // axe y start datetime labelposition; // label position on screen double ratioposition=0.80; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { int i; string objectline; if(Digits==2){minus=0;} if(Digits==3){minus=1;} if(Digits==4){minus=0;} if(Digits==5){minus=1;} labelposition=Time[WindowFirstVisibleBar()/3*2]; pips=Point; if(Digits==3 || Digits==5)pips*=10; if(!Commentornot) { RectLabelCreate(0,"KcSRc_RecMov",0,x,y,10,10,clrBlack,BORDER_FLAT,CORNER_LEFT_UPPER,Textcolor,STYLE_SOLID,3,false,true,true,0); // Mouse Price Position ObjectCreate("KcSRc_Mouse",OBJ_LABEL,0,0,0); ObjectSet("KcSRc_Mouse",OBJPROP_CORNER,0); ObjectSet("KcSRc_Mouse",OBJPROP_XDISTANCE,50); ObjectSet("KcSRc_Mouse",OBJPROP_YDISTANCE,140); // Support / Resistantce information ObjectCreate("KcSRc_iRSinfo",OBJ_LABEL,0,0,0); ObjectSet("KcSRc_iRSinfo",OBJPROP_CORNER,0); ObjectSet("KcSRc_iRSinfo",OBJPROP_XDISTANCE,50); ObjectSet("KcSRc_iRSinfo",OBJPROP_YDISTANCE,155); ObjectSetText("KcSRc_iRSinfo","",10,"Courier New",Textcolor); Comment(""); } else { ObjectDelete(0,"KcSRc_iRSinfo"); ObjectDelete(0,"KcSRc_Mouse"); ObjectDelete(0,"KcSRc_RecMov"); } for(i=ObjectsTotal() -1; i>=0; i--) { if(StringFind(ObjectName(i),"KcSR_")>-1) { objectline=ObjectName(i); StringReplace(objectline,"KcSR_",""); if(StringSubstr(objectline,0,StringFind(objectline,"_"))==Symbol()) { ObjectSetInteger(0,ObjectName(i),OBJPROP_TIMEFRAMES,OBJ_ALL_PERIODS); if(StringFind(ObjectName(i),"_RS")>-1) { ObjectSetInteger(0,ObjectName(i),OBJPROP_SELECTABLE,true); ObjectSetInteger(0,ObjectName(i),OBJPROP_SELECTED,true); } } if(StringSubstr(objectline,0,StringFind(objectline,"_"))!=Symbol()) { ObjectSetInteger(0,ObjectName(i),OBJPROP_TIMEFRAMES,OBJ_NO_PERIODS,EMPTY); } } } ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,1); WindowRedraw(); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { return; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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 i; string objectline; string result[]; double PipGap; string PipGapValue; ObjectSet("KcSRc_Mouse",OBJPROP_XDISTANCE,ObjectGet("KcSRc_RecMov",OBJPROP_XDISTANCE)); ObjectSet("KcSRc_Mouse",OBJPROP_YDISTANCE,ObjectGet("KcSRc_RecMov",OBJPROP_YDISTANCE)+10); ObjectSet("KcSRc_iRSinfo",OBJPROP_XDISTANCE,ObjectGet("KcSRc_RecMov",OBJPROP_XDISTANCE)); ObjectSet("KcSRc_iRSinfo",OBJPROP_YDISTANCE,ObjectGet("KcSRc_RecMov",OBJPROP_YDISTANCE)+25); //test trendline //Print(ObjectGetValueByTime(0,"Trendline 47604",TimeCurrent())); for(i=ObjectsTotal() -1; i>=0; i--) { if(StringFind(ObjectName(i),"KcSR_"+Symbol())>-1) { if(StringFind(ObjectName(i),"_label")>-1) { objectline=ObjectName(i); StringReplace(objectline,"_label","_RS"); ObjectMove(0,ObjectName(i),0,labelposition,ObjectGet(objectline,OBJPROP_PRICE1)); PipGap=MathAbs(MarketInfo(Symbol(),MODE_BID)-ObjectGet(objectline,OBJPROP_PRICE1)); ObjectSetString(0,ObjectName(i),OBJPROP_TEXT,DoubleToString(ObjectGet(objectline,OBJPROP_PRICE1),Digits)+" / "+DoubleToString(PipGap/pips,1)+" Pips"); PipGapValue=DoubleToString(PipGap*MarketInfo(Symbol(),MODE_TICKVALUE)/MarketInfo(Symbol(),MODE_TICKSIZE)*DefaultLotSize,2); ObjectSetString(0,ObjectName(i),OBJPROP_TOOLTIP,DoubleToString(ObjectGet(objectline,OBJPROP_PRICE1),Digits)+" / "+DoubleToString(PipGap/pips,1)+" Pips / "+PipGapValue+" "+AccountInfoString(ACCOUNT_CURRENCY)); ObjectSetString(0,objectline,OBJPROP_TOOLTIP,DoubleToString(ObjectGet(objectline,OBJPROP_PRICE1),Digits)+" / "+DoubleToString(PipGap/pips,1)+" Pips / "+PipGapValue+" "+AccountInfoString(ACCOUNT_CURRENCY)); } } if(StringFind(ObjectName(i),"_RS")>-1) { if(ObjectGet(ObjectName(i),OBJPROP_PRICE1)-1) { //Print(ObjectGetValueByTime(0,ObjectName(i),TimeCurrent())); if(!(ObjectGet(ObjectName(i),OBJPROP_COLOR)==LineSupportcolor) && !(ObjectGet(ObjectName(i),OBJPROP_COLOR)==LineResistcolor)) {//just added if(ObjectGetValueByTime(0,ObjectName(i),TimeCurrent())