[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 13

 

What kind of men you are, you can't help a poor girl, all I ask is such a trifle.

Here's a link to coloured MA, for example.https://www.mql5.com/ru/code/9145

I just need an example, but simpler and clearer with one coloured line on tops or bottoms of bars, without calculation algorithms.

Please respond to my request. Thank you in advance.

 
rigonich:


In order to draw an indicator line, you should:

1. create arrays with certain properties, called indicator buffers, from which the coordinates of the points used to construct the indicator line will be taken. Ready-made functions built into the terminal are used for this purpose.

2. set the style of drawing of the indicator line by selecting it among the available options. this can also be done using built-in functions of the terminal.

3. fill this array with some values. this is done in the function for starting the indicator. and start the program drawing the indicator.

The terminal has no built-in function that changes the drawing style of one buffer, i.e. it can draw different parts of one line in different styles. This requires the creation of a custom function, but it is not easy, and you should know at least the basics of programming.

I understand it, I don't know how to stop the red line on a bar, for example i=20, start the green line from this bar, etc.
 
Yulia:

What kind of men you are, you can't help a poor girl, all I ask is such a trifle.

Here's a link to coloured MA, for example.https://www.mql5.com/ru/code/9145

I just need an example, but simpler and clearer with one coloured line on tops or bottoms of bars, without calculation algorithms.

Please respond to my request. Thank you in advance.


Examples of such indicators in kodobase, but they are not simple, because this indicator cannot be made using only built-in terminal tools, because the necessary built-in tools for this are absent in the terminal (I mean, tools for building indicators).
 

Professionals, how can I store data for several days and then edit this data?

I know about php, but MySQL database is used to store some data,

I can't understand how to store some information and where to put it to be able to use and edit it later?

If there is such a thing in mql4 please explain it with a little example.

Here's what I need to do: take the amount of available funds in the account at that moment, enter it into the database, and after the EA has traded 10% more or less, we increase the lot or decrease it based on the new amount.

This is what the database is for, to remember that now there is $1000 in the account

Once the EA has reached $1100, increase the lot.

Suma = 1100; // the current amount is $100 more, the Expert Advisor has successfully traded.

procent = 10; // 10%

baza = 1000; // we have extracted the previous amount from the database.

raznica = (baza/procent)+baza;// we take 1000/10=100, the difference is 10% and add it to the amount from the base we get 100+1000=1100


if (Suma>=raznica ) // 1100 >=1100 compare if the current amount is more than the sum from the base + 10%;

{

we increase the lot and add the amount of 1100 to the base; after the EA trades the amount of 10% of 1100=110, we again increase the lot and add the new amount to the base, etc.

}


I hope I explained it well. maybe there are other ideas or solutions on how to implement this?

 
pasha5282:

Professionals, how can I store data for several days and then edit this data?

I know about php, but MySQL database is used to store some data,

I can't understand how to store some information and where to put it to be able to use and edit it later?

If there is such a thing in mql4 please explain it with a little example.

Here's what I need to do: take the amount of available funds in the account at that moment, enter it into the database, and after the EA has traded 10% more or less, we increase the lot or decrease it based on the new amount.

This is what the database is for, to remember that now there is $1000 in the account

Once the EA has reached $1100, increase the lot.

Suma = 1100; // the current amount is $100 more, the Expert Advisor has successfully traded.

procent = 10; // 10%

baza = 1000; // we have extracted the previous amount from the database.

raznica = (baza/procent)+baza;// we take 1000/10=100, the difference is 10% and add it to the amount from the base we get 100+1000=1100


if (Suma>=raznica ) // 1100 >=1100 compare if the current amount is more than the sum from the base + 10%;

{

we increase the lot and add the amount of 1100 to the base; after the EA trades the amount of 10% of 1100=110, we again increase the lot and add the new amount to the base, etc.

}


I hope I explained it well. maybe there are other ideas or solutions on how to implement this?


Variables or arrays of variables are used for this purpose. In fact, MySQL is also an array of variables and a set of rules that allow you to work with this array.
 
Yulia:
It is clear to me, I do not know how on a bar, for example i=20 to stop the red line, from this bar to start the green one, etc.
For a line to be drawn in different colours (it is assembled from separate "pieces" of lines of different colours), you need to activate as many buffers as you want the colours of the line being drawn.

In your example, on the 20th bar the values must be put into the buffer that draws the green line, and all other buffers on that bar must have an Empty value that is not drawn on the chart. It defaults to EMPTY_VALUE.


P.S. The coloured MA link you cited is elementary and very clear to implement what I wrote to you above.

 
TarasBY:
For a line to be drawn in different colours (it is assembled from separate "pieces" of lines of different colours), you must use as many buffers as you want the line to be drawn in.
In your example, on bar 20, you would put values into the buffer that draws the green line, while all other buffers on that bar should have an empty value that is not drawn on the chart. It defaults to EMPTY_VALUE.

to be more precise, not how many colours, but how many bars, and the maximum number of indicator buffers -- 8...
 
TarasBY:
For a line to be drawn in different colours (it is collected from separate "pieces" of lines of different colours), you need to use as many buffers, as you want colours for the drawn line.
In your example, on bar 20, you would put values into the buffer that draws the green line, while all other buffers on that bar should have an empty value that is not drawn on the chart. It defaults to EMPTY_VALUE.

I tried everything, if I put value of 20 bar in green buffer then red is drawn further, if I assign EMPTY_VALUE to red buffer 20, then red to 20 is not drawn. Please show me an example, I would be very grateful to you

//--------------------------------------------------------------------
// userindicator.mq4 // Intended for use as an example in MQL4 tutorial.
//--------------------------------------------------------------------
#property indicator_chart_window//The indicator is drawn in the main window
#property indicator_buffers 2 // number of buffers
#property indicator_color1 Red// colour of the first line
#property indicator_color2 Green// colour of the second line

double Buf_0[],Buf_1[]; //declaration of arrays (for indicator buffers)
//--------------------------------------------------------------------
int init() {// Special function init()
SetIndexBuffer(0,Buf_0);// assignment of an array to the buffer
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);//Line style
SetIndexBuffer(1,Buf_1);// assigning an array to the buffer
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);//Line style
return; // Exit from the special init. init()
}
//-------------------------------------------------------------------
int start() { // special function start( )
int i,// bar index
Counted_bars; // Number of bars counted
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted();//number of calculated bars
i=Bars-Counted_bars-1;// Index of the first one not counted

while(i>=0) // loop through the uncounted bars
{

Buf_0[i]=High[i];
Buf_1[i]=
i--;

}
return;
}

 
How do I get the code right here? Do I have to use Scr? What do I have to do to put the code into the comment?
 
rigonich:

To be more precise, not how many colours, but how many bars, and the maximum number of indicator buffers -- 8...

Have you thought about the bars well??? Look at the coloured MA on the link, put it on your chart with a period of, say, 14, and count the number of bars of different colours there.

Or you are talking about "Thomas" and I'm talking about "Eurya"...

Reason: