boolObjectCreate(
long chart_id, // chart identifierstring name, // object nameENUM_OBJECT type, // object type
sub_window nwin, // window indexdatetime time1, // time of the first anchor pointdouble price1, // price of the first anchor point
...
datetime timeN=0, // time of the N-th anchor pointdouble priceN=0, // price of the N-th anchor point
...
datetime time30=0, // time of the 30th anchor pointdouble price30=0// price of the 30th anchor point
);
//+------------------------------------------------------------------+//| Create a text label |//+------------------------------------------------------------------+bool LabelCreate(constlong chart_ID=0, // chart's IDconststring name="Label", // label nameconstint sub_window=0, // subwindow indexconstint x=0, // X coordinateconstint y=0, // Y coordinateconstENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // chart corner for anchoringconststring text="Label", // textconststring font="Arial", // fontconstint font_size=10, // font sizeconstcolor clr=clrRed, // colorconstdouble angle=0.0, // text slopeconstENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // anchor typeconstbool back=false, // in the backgroundconstbool selection=false, // highlight to moveconstbool hidden=true, // hidden in the object listconstlong z_order=0) // priority for mouse click
{
//--- reset the error valueResetLastError();
//--- create a text labelif(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
{
Print(__FUNCTION__,
": failed to create text label! Error code = ",GetLastError());
return(false);
}
//--- set label coordinatesObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- set the chart's corner, relative to which point coordinates are definedObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
//--- set the textObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
//--- set text fontObjectSetString(chart_ID,name,OBJPROP_FONT,font);
//--- set font sizeObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
//--- set the slope angle of the textObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
//--- set anchor typeObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set colorObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- display in the foreground (false) or background (true)ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the label by mouseObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object listObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chartObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful executionreturn(true);
}
//+------------------------------------------------------------------+
Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_LABEL - Reference on algorithmic/automated trading language for MetaTrader 5
I am just worrying that I couldn't explained my issue that I want to ask did you tried it, please? Then you can know what is my problem with that code.
I just try like this - 1. I added my example file to the chart then I close MT4. 2. Open MT4 - then I do not see my Inside Label Object.
That's what I try to find solution to my issue. : /
Maybe I will be for sure Monday.
( when I think this is so easy I spend a lot of time for that easy things - when I think this is so hard that I did them so easily... - Almost all of what I want to do. first I try to read documentation... )
Once I solve my this issue - my indicator works good in my main MT4 platform - but I use 2nd MT4 platform which is my indicator needs refresh when I start MT4 platform. I have no idea where that problem comes from... that I ask something exactly about that.
Q: Can anyone let me something about this weird situation, please?
What a secret of load template? There is mystical things, which is destroying me at all... that is really really making me mad at all... - I have already did huge things for my EA's and Indicator's that I never spent a lot of time like I am spending few minor issues...
How? Simple!
After I decided that I should not put some scripts in my EA's files - then I continuously facing minors issues that I can't find solution in SEO. ( actually sometimes I find easily solution to my huge EA's issues on SEO - but this minor issues. )
---
I put this simple code in my example indicator file.
When I try to load this example file to my chart. It does not work correctly until I change TimeFrame. ( it's possible I already tired today ) ( also I know I can solve this issue if I put that code in OnCalculate(...) - but I just need to put that code in OnInit() )
Please, I just need more clearly explanation for this issue. I really need it, because few my indicators have same irrelevant issues. ( that if I put this in my EA's files it will work correctly )
Oh ok that code.
ObjectCreate() also needs the chart ID:
As the first parameter.
But you start with the objectname.
Also you can specify a base corner/anchor point.
Please see: https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_label
I am just worrying that I couldn't explained my issue that I want to ask did you tried it, please? Then you can know what is my problem with that code.
I just try like this - 1. I added my example file to the chart then I close MT4. 2. Open MT4 - then I do not see my Inside Label Object.
That's what I try to find solution to my issue. : /
Maybe I will be for sure Monday.
( when I think this is so easy I spend a lot of time for that easy things - when I think this is so hard that I did them so easily... - Almost all of what I want to do. first I try to read documentation... )
I tried it and there are two objects shown.
Cool!
Look my screenshot, please.
Thanks a lot for your time Mr. Marco
I never mind that part of code will give me different result in Indicator. : /
I try that part of code in my Indicator File.
( I decided that I will write some code in indicator files just not in my Trade Panel file. )
2nd time edited
I already use your method - now it works without any issues, hope it will work.
Thanks a lot Mr. Marco
#Not Monday - Closed
#Refresh - Open
Once I solve my this issue - my indicator works good in my main MT4 platform - but I use 2nd MT4 platform which is my indicator needs refresh when I start MT4 platform.
I have no idea where that problem comes from... that I ask something exactly about that.
Q: Can anyone let me something about this weird situation, please?
Thanks in advance.
You mean you witness different behavior between two platforms?
Are they the same build?
You mean you witness different behavior between two platforms?
Are they the same build?
Yeah absolutely different behavior...
Also yes both of them 1065 Build
Maybe I found where comes those weird issues...
What a secret of load template?
There is mystical things, which is destroying me at all... that is really really making me mad at all... - I have already did huge things for my EA's and Indicator's that I never spent a lot of time like I am spending few minor issues...
How? Simple!
After I decided that I should not put some scripts in my EA's files - then I continuously facing minors issues that I can't find solution in SEO. ( actually sometimes I find easily solution to my huge EA's issues on SEO - but this minor issues. )
---
I put this simple code in my example indicator file.
When I try to load this example file to my chart. It does not work correctly until I change TimeFrame.
( it's possible I already tired today )
( also I know I can solve this issue if I put that code in OnCalculate(...) - but I just need to put that code in OnInit() )
Please, I just need more clearly explanation for this issue. I really need it, because few my indicators have same irrelevant issues. ( that if I put this in my EA's files it will work correctly )
Thanks in advance.
Have a nice weekend.