Pointers in MQL4 are tricky. There is no direct support. Someone here on the forum tried to do it with arrays, I think. I can't be more precise. Search for it yourself.
You can change only the first dimension of the array programmatically. The ArrayResize() function. The second, third and fourth dimensions have to be set rigidly.
Well, let's forget about pointers and dynamic arrays too...
Looking forward to the 5th version of the language...
Thanks for the help...
Working with one grid is easy to implement.
Funny thing is, for my idea one network was not enough, and I wanted to make an algorithm for switching between networks, with pointers it's not hard.
This function sets the OBJ_TRENDBYANGLE object of the trend line by the slope angle on the current chart.
cl - Color of the TRENDBYANGLE object. Required parameter.
nm - Object name. When the default value is passed - "", the open time of the current bar is used as the name.
t1 - First coordinate of object setting time. Default value - 0 - open time of the tenth bar.
p1 - First coordinate of object setting price. Default value - 0 - minimum of the tenth bar.
t2 - Second coordinate of object setting time. Default value - 0 - open time of the current bar.
p2 - Second coordinate of object setting price. This parameter is a kind of switch. Its non-zero value equates this function to SetTLine(), i.e. a trend line will be drawn using the time/price coordinate pair, while the value of the slope angle of the trend line will be ignored. Default value - 0 - trend line construction by slope angle.
an - Slope angle in degrees. Default value - 0 - Horizontal line.
ry - Flag of the BOW property. The default value is False.
st - Line style. Valid values are STYLE_SOLID (default), STYLE_DASH, STYLE_DOT, STYLE_DASHDOT.
wd - Line width. Default value is 1.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 12.10.2007 |//| Описание : Установка объекта OBJ_TRENDBYANGLE трендовая линия по углу |//+----------------------------------------------------------------------------+//| Параметры: |//| cl - цвет линии |//| nm - наименование ( "" - время открытия текущего бара) |//| t1 - время открытия бара ( 0 - Time[10] |//| p1 - ценовой уровень ( 0 - Low[10]) |//| t2 - время открытия бара ( 0 - время открытия текущего бара) |//| p2 - ценовой уровень ( 0 - по углу) |//| an - угол ( 0 - по умолчанию) |//| ry - луч (False - не луч) |//| st - стиль линии ( 0 - простая линия) |//| wd - ширина линии ( 1 - по умолчанию) |//+----------------------------------------------------------------------------+voidSetTLineByAngle(colorcl, stringnm="",
datetimet1=0, doublep1=0, datetimet2=0, doublep2=0,
doublean=0, boolry=False, intst=0, intwd=1){if(nm=="")nm=DoubleToStr(Time[0], 0);
if(t1<=0)t1=Time[10];
if(p1<=0)p1=Low[10];
if(t2<=0)t2=Time[0];
if(ObjectFind(nm)<0)ObjectCreate(nm, OBJ_TRENDBYANGLE, 0, 0,0);
ObjectSet(nm, OBJPROP_TIME1 , t1);
ObjectSet(nm, OBJPROP_PRICE1, p1);
ObjectSet(nm, OBJPROP_TIME2 , t2);
if(p2>0)ObjectSet(nm, OBJPROP_PRICE2, p2);
elseObjectSet(nm, OBJPROP_ANGLE, an);
ObjectSet(nm, OBJPROP_COLOR, cl);
ObjectSet(nm, OBJPROP_RAY , ry);
ObjectSet(nm, OBJPROP_STYLE, st);
ObjectSet(nm, OBJPROP_WIDTH, wd);
}
This function sets the OBJ_ARROW object icon to the current chart.
cd - icon code. Required parameter.
cl - Color of the icon. Required parameter.
nm - Name of the object. If default value is transferred - "", the open time of current bar is used as a name.
t1 - First coordinate of object's setting time. Default value - 0 - current bar open time.
p1 - First coordinate of object setting price. Default value - 0 - current Bid price.
sz - Size of the icon. Default value - 0.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 12.10.2007 |//| Описание : Установка значка на графике, объекта OBJ_ARROW. |//+----------------------------------------------------------------------------+//| Параметры: |//| cd - код значка |//| cl - цвет значка |//| nm - наименование ("" - время открытия текущего бара) |//| t1 - время открытия бара (0 - текущий бар) |//| p1 - ценовой уровень (0 - Bid) |//| sz - размер значка (0 - по умолчанию) |//+----------------------------------------------------------------------------+voidSetArrow(intcd, colorcl,
stringnm="", datetimet1=0, doublep1=0, intsz=0){if(nm=="")nm=DoubleToStr(Time[0], 0);
if(t1<=0)t1=Time[0];
if(p1<=0)p1=Bid;
if(ObjectFind(nm)<0)ObjectCreate(nm, OBJ_ARROW, 0, 0,0);
ObjectSet(nm, OBJPROP_TIME1 , t1);
ObjectSet(nm, OBJPROP_PRICE1 , p1);
ObjectSet(nm, OBJPROP_ARROWCODE, cd);
ObjectSet(nm, OBJPROP_COLOR , cl);
ObjectSet(nm, OBJPROP_WIDTH , sz);
}
Thank you very much for what you do, do you mind if I collect the features from this thread, and post them on my website, in a separate section with a link to the forum, and to your site
In general, it would be cool to have a "Table of Contents" on the first page of this post. A table with a list of functions, descriptions and links to pages. Or keep one updated archive on the first page, and the descriptions can be found on the other pages.
So, if xrust will make his suggestion, it would be good to repeat it here. For the sake of systematization of the hard-earned :))
xrust писал (а)>> ...do you mind if I collect features from this thread, and post them on my website, in a separate section with a link to the forum, and to your site
xrust писал (а)>> Thank you very much for what you're doing, would you mind if I collect the functions from this branch, and post them on my site, in a separate section with a reference to the forum and your site
Create an "inluder" file (mqh) (probably 2 - "trade" and "other"), agree on its name and force the "developers" to include it in the distribution. So that everyone in each EA does not have to reinvent the wheel.
Thank you again, I'm just a little lazy, I want to collect everything at hand. Another question, would you mind if I use the same syntax and variable names in my functions as you do, to standardize them, so to speak.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Pointers in MQL4 are tricky. There is no direct support. Someone here on the forum tried to do it with arrays, I think. I can't be more precise. Search for it yourself.
MathRand()
You can change only the first dimension of the array programmatically. The ArrayResize() function. The second, third and fourth dimensions have to be set rigidly.Well, let's forget about pointers and dynamic arrays too...
Looking forward to the 5th version of the language...
Thanks for the help...
Working with one grid is easy to implement.
Funny thing is, for my idea one network was not enough, and I wanted to make an algorithm for switching between networks, with pointers it's not hard.
But no... ...we'll have to hardcode it.
The SetTLineByAngle() function.
This function sets the OBJ_TRENDBYANGLE object of the trend line by the slope angle on the current chart.
Examples of how to use SetTLineByAngle().
ZY. Attached is a script for testing SetTLineByAngle().
The SetArrow() function.
This function sets the OBJ_ARROW object icon to the current chart.
Examples of how to use SetArrow().
SZY. Attached is a script to test the SetArrow() function.
In general, it would be cool to have a "Table of Contents" on the first page of this post. A table with a list of functions, descriptions and links to pages. Or keep one updated archive on the first page, and the descriptions can be found on the other pages.
So, if xrust will make his suggestion, it would be good to repeat it here. For the sake of systematization of the hard-earned :))
...do you mind if I collect features from this thread, and post them on my website, in a separate section with a link to the forum, and to your site
No, I won't...
Thank you very much for what you're doing, would you mind if I collect the functions from this branch, and post them on my site, in a separate section with a reference to the forum and your site
Create an "inluder" file (mqh) (probably 2 - "trade" and "other"), agree on its name and force the "developers" to include it in the distribution. So that everyone in each EA does not have to reinvent the wheel.
:)