kinjal parekh: i want to draw ray on mt5 charts with text lable.
There are text objects and there are label objects. There are no "text lable" objects.
You want to draw — no indicator required.
kinjal parekh:
hello,
i want to draw ray on mt5 charts with text lable. dose anyone know any indiactor can do this?
thanks
Hello .
Try this .
Its an indicator , place it in indicators folder .
cheers
#property copyright "Mql5.com forum thread >>" #property link "https://www.mql5.com/en/forum/350123" #property description "Telegram : https://t.me/lorentzor\nInstagram : @rlorentzo\nTwitter : @lorentzo_r\nLinkedIn : https://www.linkedin.com/in/lorentzor\nYoutube : https://www.youtube.com/channel/UCM0Lj06cAJagFWvSpb9N5zA\nFacebook : @LorentzoR" /* ways to connect .> : Telegram : https://t.me/lorentzor Instagram : https://www.instagram.com/rlorentzo /OR/ @rlorentzo Twitter : https://twitter.com/lorentzo_r /OR/ @lorentzo_r LinkedIn : https://www.linkedin.com/in/lorentzor Youtube : https://www.youtube.com/channel/UCM0Lj06cAJagFWvSpb9N5zA Facebook : https://www.facebook.com/LorentzoR /OR/ @LorentzoR Mql5.com : https://www.mql5.com/en/users/lorio */ #property version "1.00" #property indicator_chart_window input bool AnchorStep=true;//Have Tag Anchor Step ? input bool CommentGuides=true;//Comment Guides ? input bool TagPrices=true;//Tag Prices ? input bool TagTimeframes=true;//Tag Timeframes ? input color LinesColor=clrDodgerBlue;//Lines Color input int LinesWidth=2;//Lines Width input ENUM_LINE_STYLE LinesStyle=STYLE_SOLID;//Lines Style input bool WithTags=true;//With Tags ? input ENUM_ANCHOR_POINT TagAnchor=ANCHOR_RIGHT_LOWER;//Default Tag Anchor input string TagFont="Arial";//Tags font input int TagFontSize=12;//Tags Font Size input color TagColor=clrOrangeRed;//Tags Color input int MouseClickDeflector=400;//Deflector milliseconds input int ButtonPx=10;//Button Position X input int ButtonPy=30;//Button Position Y input int ButtonSx=200;//Button Size X input int ButtonSy=20;//Button Size Y input int ButtonFontSize=10;//Button Font Size input string ButtonFont="Arial";//Button Font input string ButtonText="New Line>";//Button text //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ string SystemTag="mrLines_",LinesTag="FL_"; string state_comment[],tfname=""; datetime Time100,Time1;//bad simplification int OnInit() { //--- indicator buffers mapping tfname=TFtoString(_Period); ArrayResize(state_comment,2,0); state_comment[0]="Position Price <=="; if(AnchorStep){for(int i=0;i<1;i++){state_comment[i]+="\nAlign Tag";}} state_comment[1]="Position Price\nAlign Tag <=="; mrLines.Abort(false,true); ChartSetInteger(ChartID(),CHART_EVENT_MOUSE_MOVE,true); Time100=(datetime)(TimeCurrent()-PeriodSeconds()*100); Time1=TimeCurrent(); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ uint ClickMS=0; int Mcx=0,Mcy=0,PreMcx=0,PreMcy=0; string Mcc,PreMcc; void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- //mousemove //just a click bool click_through=false; if(id==CHARTEVENT_CLICK&&mrLines.State!=eol_none){click_through=true;} if(id==CHARTEVENT_MOUSE_MOVE||click_through) { PreMcx=Mcx;PreMcy=Mcy;PreMcc=Mcc; Mcx=(int)lparam;Mcy=(int)dparam;Mcc=sparam; if(click_through){Mcc="1";} if(PreMcc=="0"&&Mcc!="0") { uint now=GetTickCount(); int diff=(int)(now-ClickMS); if(now<ClickMS){diff=(int)(now)+(int)(UINT_MAX-ClickMS);} if(diff<=MouseClickDeflector){Mcc="0";} if(diff>MouseClickDeflector){ClickMS=now;} } //tag positioning if(mrLines.State==eol_anchor) { double pr=0;datetime ti=0;int subw=0; bool get_price=ChartXYToTimePrice(ChartID(),Mcx,Mcy,subw,ti,pr); //if price is accesed if(get_price){mrLines.ChangeTagAnchor(pr,ti);} //if click mouse button 2 - kill if(Mcc=="2"){mrLines.Abort(true,true);} //if click mouse button 1 - finish if(Mcc=="1"){mrLines.Abort(false,true);} } //tag positioning ends here //if moving the price if(mrLines.State==eol_price) { double pr=0;datetime ti=0;int subw=0; bool get_price=ChartXYToTimePrice(ChartID(),Mcx,Mcy,subw,ti,pr); //if price is accesed if(get_price){mrLines.ChangePrice(pr);} //if click mouse button 2 - kill if(Mcc=="2"){mrLines.Abort(true,true);} //if click mouse button 1 - proceed to tag or finalize if(Mcc=="1") { if(WithTags&&AnchorStep){mrLines.State=eol_anchor;Comment(state_comment[1]);PreMcc="0";Mcc="0";} if(!WithTags||!AnchorStep){mrLines.Abort(false,true);PreMcc="0";Mcc="0";} } } //if moving the price ends here } //mousemove ends here //click on new line if(id==CHARTEVENT_OBJECT_CLICK&&sparam==SystemTag+"_Make_Line") { string get_text=ObjectGetString(ChartID(),SystemTag+"_Line_Label",OBJPROP_TEXT); double pr=0;datetime ti=0;int subw=0; bool get_price=ChartXYToTimePrice(ChartID(),Mcx,Mcy,subw,ti,pr); //if price is accesed if(get_price) { ObjectsDeleteAll(ChartID(),SystemTag); //get mouse scroll state mrLines.ScrollState=(bool)ChartGetInteger(ChartID(),CHART_MOUSE_SCROLL); if(mrLines.ScrollState){ChartSetInteger(ChartID(),CHART_MOUSE_SCROLL,false);} //set to stage 1 price positioning //initial price mrLines.Price=pr; mrLines.State=eol_price; ClickMS=GetTickCount(); PreMcc="0";Mcc="0"; mrLines.LineName=LinesTag+"_"+IntegerToString(TimeLocal()); mrLines.TagAnchored=TagAnchor; mrLines.TagSide=1;//B mrLines.HasTag=WithTags; mrLines.Cid=ChartID(); mrLines.SubW=0; if(CommentGuides){Comment(state_comment[0]);} mrLines.LineLabelBase=get_text; string tag_text=get_text; if(TagPrices){tag_text+=" "+DoubleToString(pr,Digits());} if(TagTimeframes){tag_text+=" ["+tfname+"]";} CreateHLWT(ChartID(),0,mrLines.LineName,WithTags,TagAnchor,tag_text,true,Time100,true,Time1,pr,pr,LinesColor,LinesWidth,LinesStyle,TagColor,TagFontSize,false,false,false,false); ChartRedraw(ChartID()); } //if price is accessed ends here } //click on new line ends here } //+------------------------------------------------------------------+ enum editor_state{ eol_none=0, eol_price=1,//placing price eol_anchor=2//placing Anchor }; struct editor_of_lines { editor_state State; long Cid; int SubW; bool ScrollState,HasTag; string LineName,LineLabelBase; double Price; datetime PointA,PointB; ENUM_ANCHOR_POINT TagAnchored; int TagSide;//0 point a ,1 point b editor_of_lines(void){State=eol_none;LineName=NULL;} ~editor_of_lines(void){Abort(true,false);} //NEW PRICE : void ChangePrice(double new_price){ Price=new_price; ObjectSetDouble(Cid,LineName,OBJPROP_PRICE,1,new_price); ObjectSetDouble(Cid,LineName,OBJPROP_PRICE,2,new_price); if(HasTag){ ObjectSetDouble(Cid,LineName+"_tag",OBJPROP_PRICE,new_price); string tag_text=LineLabelBase; if(TagPrices){tag_text+=" "+DoubleToString(Price,Digits());} if(TagTimeframes){tag_text+=" ["+tfname+"]";} ObjectSetString(Cid,LineName+"_tag",OBJPROP_TEXT,tag_text); } ChartRedraw(ChartID()); } //CHANGE ANCHOR void ChangeTagAnchor(double mouseprice,datetime mousetime){ TagSide=1; //find new anchor //above price if(mouseprice>Price){ //and left side if(TagSide==0){TagAnchored=ANCHOR_LEFT_LOWER;} //and right side if(TagSide==1){TagAnchored=ANCHOR_RIGHT_LOWER;} } //below price if(mouseprice<=Price){ //and left side if(TagSide==0){TagAnchored=ANCHOR_LEFT_UPPER;} //and right side if(TagSide==1){TagAnchored=ANCHOR_RIGHT_UPPER;} } ObjectSetInteger(Cid,LineName+"_tag",OBJPROP_ANCHOR,TagAnchored); ChartRedraw(ChartID()); } //Abort void Abort(bool kill_line_under_edit,bool deckup){ if(CommentGuides){Comment("");} //delete objects created if(kill_line_under_edit&&LineName!=NULL){ObjectsDeleteAll(Cid,LineName);} LineName=NULL; //reset state State=eol_none; //restore mouse scroll if(ScrollState){ChartSetInteger(Cid,CHART_MOUSE_SCROLL,true);} //create btn if(deckup){DeckUp();} } //Button void DeckUp(){ ObjectsDeleteAll(ChartID(),SystemTag); HS_Create_Btn(ChartID(),0,SystemTag+"_DivHTML",ButtonSx+4,ButtonSy*2+10,ButtonPx-2,ButtonPy-5,"",0,clrRoyalBlue,clrMidnightBlue,BORDER_FLAT,clrNONE,ALIGN_CENTER,"",false,false); HS_Create_Edit(ChartID(),0,SystemTag+"_Line_Label",ButtonSx,ButtonSy,ButtonPx,ButtonPy,ButtonFont,ButtonFontSize,C'40,40,40',clrBlack,BORDER_FLAT,clrOrange,ALIGN_CENTER,"New Label",false,false,false); HS_Create_Btn(ChartID(),0,SystemTag+"_Make_Line",ButtonSx,ButtonSy,ButtonPx,ButtonPy+ButtonSy,ButtonFont,ButtonFontSize,clrRoyalBlue,clrDodgerBlue,BORDER_FLAT,clrGoldenrod,ALIGN_CENTER,ButtonText,false,false); ChartRedraw(ChartID()); } }; editor_of_lines mrLines; //Period to Timeframe ENUM_TIMEFRAMES PeriodToTF(int period) { if(period==1) return(PERIOD_M1); if(period==5) return(PERIOD_M5); if(period==15) return(PERIOD_M15); if(period==30) return(PERIOD_M30); if(period==60) return(PERIOD_H1); if(period==240) return(PERIOD_H4); if(period==1440) return(PERIOD_D1); if(period==10080) return(PERIOD_W1); if(period==43200) return(PERIOD_MN1); return(PERIOD_CURRENT); } //Timeframe To String string TFtoString(ENUM_TIMEFRAMES TF) { string returnio=""; if(TF==PERIOD_M1) returnio="M1"; if(TF==PERIOD_M5) returnio="M5"; if(TF==PERIOD_M15) returnio="M15"; if(TF==PERIOD_M30) returnio="M30"; if(TF==PERIOD_H1) returnio="H1"; if(TF==PERIOD_H4) returnio="H4"; if(TF==PERIOD_D1) returnio="D1"; if(TF==PERIOD_W1) returnio="W1"; if(TF==PERIOD_MN1) returnio="MN1"; return(returnio); } //CREATE HORIZONTAL LINE WITH TAG void CreateHLWT(long cid, int subw, string line_name, bool has_tag, ENUM_ANCHOR_POINT tag_anchor, string tag_text, bool infinite_left, datetime start_time, bool infinite_right, datetime end_time, double start_price, double end_price, color line_color, int line_width, ENUM_LINE_STYLE line_style, color tag_color, int tag_font_size, bool back, bool selectable, bool tag_back, bool tag_selectable) { bool obji=ObjectCreate(cid,line_name,OBJ_TREND,subw,0,start_price,end_time,end_price); ObjectSetInteger(cid,line_name,OBJPROP_BACK,back); ObjectSetInteger(cid,line_name,OBJPROP_SELECTABLE,selectable); ObjectSetInteger(cid,line_name,OBJPROP_COLOR,line_color); ObjectSetInteger(cid,line_name,OBJPROP_STYLE,line_style); ObjectSetInteger(cid,line_name,OBJPROP_WIDTH,line_width); if(!infinite_left) ObjectSetInteger(cid,line_name,OBJPROP_RAY,false); if(infinite_left) ObjectSetInteger(cid,line_name,OBJPROP_RAY,true); if(!infinite_right) ObjectSetInteger(cid,line_name,OBJPROP_RAY_RIGHT,false); if(infinite_right) ObjectSetInteger(cid,line_name,OBJPROP_RAY_RIGHT,true); //if tag if(has_tag) { string objna=line_name+"_tag"; obji=ObjectCreate(cid,objna,OBJ_TEXT,subw,end_time,end_price); ObjectSetInteger(cid,objna,OBJPROP_COLOR,tag_color); ObjectSetInteger(cid,objna,OBJPROP_ANCHOR,tag_anchor); ObjectSetInteger(cid,objna,OBJPROP_FONTSIZE,tag_font_size); ObjectSetInteger(cid,objna,OBJPROP_BACK,tag_back); ObjectSetInteger(cid,objna,OBJPROP_SELECTABLE,tag_selectable); ObjectSetString(cid,objna,OBJPROP_TEXT,tag_text); } //if tag ends here } //CREATE LINE WITH TAG ENDS HERE //CREATE BTN OBJECT void HS_Create_Btn(long cid, int subw, string name, int sx, int sy, int px, int py, string font, int fontsize, color bck_col, color brd_col, ENUM_BORDER_TYPE brd_type, color txt_col, ENUM_ALIGN_MODE align, string text, bool selectable, bool back) { bool obji=ObjectCreate(cid,name,OBJ_BUTTON,subw,0,0); if(obji) { ObjectSetString(0,name,OBJPROP_FONT,font); ObjectSetInteger(0,name,OBJPROP_ALIGN,align); ObjectSetInteger(0,name,OBJPROP_FONTSIZE,fontsize); ObjectSetInteger(0,name,OBJPROP_XSIZE,sx); ObjectSetInteger(0,name,OBJPROP_YSIZE,sy); ObjectSetInteger(0,name,OBJPROP_XDISTANCE,px); ObjectSetInteger(0,name,OBJPROP_YDISTANCE,py); ObjectSetInteger(0,name,OBJPROP_BGCOLOR,bck_col); ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,brd_col); ObjectSetInteger(0,name,OBJPROP_COLOR,txt_col); ObjectSetInteger(0,name,OBJPROP_BORDER_TYPE,brd_type); ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selectable); ObjectSetInteger(0,name,OBJPROP_BACK,back); ObjectSetString(0,name,OBJPROP_TEXT,text); } } //CREATE INPUT OBJECT void HS_Create_Edit(long cid, int subw, string name, int sx, int sy, int px, int py, string font, int fontsize, color bck_col, color brd_col, ENUM_BORDER_TYPE brd_type, color txt_col, ENUM_ALIGN_MODE align, string text, bool selectable, bool readonly, bool back) { bool obji=ObjectCreate(cid,name,OBJ_EDIT,subw,0,0); if(obji) { ObjectSetString(0,name,OBJPROP_FONT,font); ObjectSetInteger(0,name,OBJPROP_ALIGN,align); ObjectSetInteger(0,name,OBJPROP_FONTSIZE,fontsize); ObjectSetInteger(0,name,OBJPROP_XSIZE,sx); ObjectSetInteger(0,name,OBJPROP_YSIZE,sy); ObjectSetInteger(0,name,OBJPROP_XDISTANCE,px); ObjectSetInteger(0,name,OBJPROP_YDISTANCE,py); ObjectSetInteger(0,name,OBJPROP_BGCOLOR,bck_col); ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,brd_col); ObjectSetInteger(0,name,OBJPROP_COLOR,txt_col); ObjectSetInteger(0,name,OBJPROP_BORDER_TYPE,brd_type); ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selectable); ObjectSetInteger(0,name,OBJPROP_READONLY,readonly); ObjectSetInteger(0,name,OBJPROP_BACK,back); ObjectSetString(0,name,OBJPROP_TEXT,text); } } //+------------------------------------------------------------------+ //| 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[]) { //--- Time100=(datetime)(TimeCurrent()-PeriodSeconds()*100); Time1=TimeCurrent(); //--- return value of prev_calculated for next call return(rates_total); }
Files:

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hello,
i want to draw ray on mt5 charts with text lable. dose anyone know any indiactor can do this?
thanks