input string InpName="HLine"; // Line name input string InpName2="HLine2"; // Line name // // // if(!HLineCreate(0,InpName,0,price[p],InpColor,InpStyle,InpWidth,InpBack, InpSelection,InpHidden,InpZOrder)) // // if(!HLineCreate(0,InpName2,0,price[p],InpColor,InpStyle,InpWidth,InpBack, InpSelection,InpHidden,InpZOrder))
ok, I see it . . . thanks
Now, is there a way to make it an indefinite number of extra "HLine" entries (maybe changing the "name" input)?
Sorry to be so ignorant, but I'm learning bit by bit. I've modified all of the extensions I used, and I search for appropriate code snippets.
ok, I see it . . . thanks
Now, is there a way to make it an indefinite number of extra "HLine" entries (maybe changing the "name" input)?
Sorry to be so ignorant, but I'm learning bit by bit. I've modified all of the extensions I used, and I search for appropriate code snippets.
input string InpName="HLine"+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES); // Line name
you only need to name it differently you can use a number, time, price,....
but be sure it is unique and simple to use in your program
ok, thanks . . .
I'll work on that and let you know my success! I'm sure it will work (I can tell by the snippets you both wrote)
You guys (and gals) have been great!
That line . . .
input string InpName="HLine"+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES); // Line name
. . . gives me an error . . .
'CreateLevels.mq4' '+'-constant expected CreateLevels.mq4 9 38 1 error(s), 0 warning(s)
ok, thanks . . .
I'll work on that and let you know my success! I'm sure it will work (I can tell by the snippets you both wrote)
You guys (and gals) have been great!
That line . . .
. . . gives me an error . . .
sorry, was only concentrating on changing objectname didn't look that quick to 'input' and where it was defined
input string InpName="HLine"; // Line name void OnStart() { //--- check correctness of the input parameters string InpName="HLine"+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES); // Line nam
if you do it this way it works
hmm . . .
It gives me one warning . . .
declaration of 'InpName' hides global declaration at line 9 CreateLevels.mq4 67 16
. . . which I understand (not a problem)
And, it allows me to put two (2) lines on the chart, and after "Compile" and "Save as," a second or third time, it allows me to put two more lines.
It needs to be "re-saved" several times before I can put more lines on the chart. I'm wanting to place lines on the chart over a period of time and keep them there.
The lines represent levels of "buy/sell" orders! I'm trying to use Market Profile to identify "liquidity levels" but I want a "band" and not a "fat" line.
I've tried modifying "ChartObjectLines" to get a "fatter" line, but all I can get is "width=5"
//+------------------------------------------------------------------+ //| Class CChartObjectTrend. | //| Purpose: Class of the "Trendline" object of chart. | //| Derives from class CChartObject. | //| It is the parent class for all objects that have properties | //| RAY_LEFT and RAY_RIGHT. | //+------------------------------------------------------------------+ class CChartObjectTrend : public CChartObject { public: CChartObjectTrend(void); ~CChartObjectTrend(void); //--- methods of access to properties of the object bool RayLeft(void) const; bool RayLeft(const bool new_sel) const; bool RayRight(void) const; bool RayRight(const bool new_sel) const; //--- method of creating the object bool Create(long chart_id,const string name,const int window, const datetime time1,const double price1, const datetime time2,const double price2, const ENUM_LINE_STYLE style=STYLE_SOLID,const int width=20, const bool back=false,const bool selection=true, const bool hidden=true,const long z_order=0); //--- method of identifying the object virtual int Type(void) const { return(OBJ_TREND); } //--- methods for working with files virtual bool Save(const int file_handle); virtual bool Load(const int file_handle); }; //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ CChartObjectTrend::CChartObjectTrend(void) { } //+------------------------------------------------------------------+ //| Destructor | //+------------------------------------------------------------------+ CChartObjectTrend::~CChartObjectTrend(void) { } //+------------------------------------------------------------------+ //| Create object "Trendline" | //+------------------------------------------------------------------+ bool CChartObjectTrend::Create(long chart_id,const string name,const int window, const datetime time1,const double price1, const datetime time2,const double price2, const ENUM_LINE_STYLE style=STYLE_SOLID,const int width=20, const bool back=false,const bool selection=true, const bool hidden=true,const long z_order=0) { if(!ObjectCreate(chart_id,name,OBJ_TREND,window,time1,price1,time2,price2)) return(false); if(!Attach(chart_id,name,window,2)) return(false); //--- successful return(true); }
It's a different approach to the same problem - "How to put a horizontal line with more width on the chart"
I appreciate your attention to the problem! What you gave me works but only to a point (and, I'll keep working on it)
I'm working on the theory that "Market Profile" gives me the prices at which "buy/sell" orders occur, and the "fat" lines represent "liquidity" levels.
Problem Solved! Thanks!
I found that the 2nd solution to my problem (i.e., modifying "ChartObjectLines") gave lines that were not always straight (especially, in the future)
So, I returned to the solutions given me above. The first . . .
input string InpName="HLine"; // Line name input string InpName2="HLine2"; // Line name // // // if(!HLineCreate(0,InpName,0,price[p],InpColor,InpStyle,InpWidth,InpBack, InpSelection,InpHidden,InpZOrder)) // // if(!HLineCreate(0,InpName2,0,price[p],InpColor,InpStyle,InpWidth,InpBack, InpSelection,InpHidden,InpZOrder))
. . . meant I'd have to multiply the "names" indefinitely. Thanks, GumRai, but it wasn't the final solution.
The second . . .
input string InpName="HLine"; // Line name void OnStart() { //--- check correctness of the input parametersth string InpName="HLine"+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES); // Line name
. . . worked when placed in the proper area. Thanks, deVries, but I found it needed an additional value . . .
input string InpName="HLine"; // Line name void OnStart() { //--- check correctness of the input parameters string InpName="HLine"+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS); // Line name
Once I understood what was happening, I saw that I could "add" two "HLines" when Price advanced by MINUTES, and when I added SECONDS, I could "add" indiscriminately.
Thanks, guys (and gals), for the help! I have it "how" I wanted it.
The "Goldenrod" horizontal lines represent the "Daily H/L" The "Teal" band represents "Value" in "Market Profile," and the "Blue" bands represent "Liquidity" levels.
I'm trying to follow the strategy of "prop trader" Ray DeMedici trading out of London.
Hi whiteEagle,
Looks very impressive !!! How is indicator working for you? Can you share the full source code please?
Thanks,
Vaikay

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've modified the code found here - https://docs.mql4.com/constants/objectconstants/enum_object/obj_hline
And, I've successfully increased the width of the horizontal line to 20
I can move it where I wish on the chart. I'm trying to create horizontal lines at the places where Market Profile shows Value, etc.
My problem is that I cannot create more than one object with the following code:
Any suggestions? How can I edit my code to allow more than one HLINE to be created? Thanks (I'm sure it's a simple problem)
FYI - My chart is an M5 chart using GMMA Long, GMMA Short, i-Sessions, Pivot Points - Shifted and Market Profile (EarnForex)