Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 238

 
Vyacheslav Kornev:
What's not to understand here. Above the bar is in a general sense. For the bottom line, it's under the bar. The leftmost point is actually where the line starts from.
The line is red at the top, pink at the bottom.

Details are important.
Wrong question - where is the right dot?
 
Artyom Trishkin:
Details are important.
Wrong question - where is the right point?
Well it is shown in the data window. Walk up the line. It's at the minimum of the penultimate one. That's the value I was able to take
 
Vyacheslav Kornev:
Well it is shown in the data window. Walk up the line. It's at the penultimate minimum. That's the value I was able to take
So the indicator has two buffers. It gives values for bar1. For bar0 you need to calculate it as I said before.
 
Artyom Trishkin:
So the indicator has two buffers. It outputs values for bar1. For bar0 you need to calculate it as I said before.
That's how I did it!
Write it completely properly.
 
Vyacheslav Kornev:
That's how I did it!
Write it completely correctly.

You need to calculate the value at bar0. Equation of a straight line:

//+------------------------------------------------------------------+
//| Уравнение прямой                                                 |
//+------------------------------------------------------------------+
double EquationDirect(const int left_bar,const double left_price,const int right_bar,const double right_price,const int bar_to_search) {
  return((right_bar==left_bar)?left_price:(right_price-left_price)/(right_bar-left_bar)*(bar_to_search-left_bar)+left_price);
}
//+------------------------------------------------------------------+

By the names of the formal variables it's all clear what to pass to the function.

Returns the value on the bar you are looking for.

 
Artyom Trishkin:

You need to calculate the value at bar0. Equation of a straight line:

By the names of the formal variables it's all clear what to pass to the function.

Returns the value at the sought bar.


Oh my goodness, it's complicated. I managed to get the value, all I have to do is write ObjectGetValueByShift, ewww. Please send me some video tutorials, I've looked at how to do indicators but didn't find that there. Everything works. Taken from the same questionhttp://www.mql5.com/ru/forum/121347

I have no idea if it's possible to make buffers like this... but it works. I don't really understand what ncurbar is.

//---- Move Object in Chart

ObjectMove("Trend DN-0",1,Time[st1],s1);

ObjectMove("Trend DN-0",0,Time[st2],s2);

Dn[nCurBar] = ObjectGetValueByShift("Trend DN-0",0);

//----

ObjectMove("Trend UP-0",1,Time[rt1],r1);

ObjectMove("Trend UP-0",0,Time[rt2],r2);

Up[nCurBar] = ObjectGetValueByShift("Trend UP-0",0);

Помогите с кодом!!!
Помогите с кодом!!!
  • 2009.10.23
  • www.mql5.com
Ситуация такая, пишу индикатор, он должен рисовать уровни поддержки и сопротивления...
 
Vyacheslav Kornev:

Oh my goodness, it's complicated. I managed to get the value, all I have to do is write ObjectGetValueByShift, ewww. Please send me some video tutorials, I've looked at how to make indicators but didn't find any such thing there. Everything works.

//---- Move Object in Chart

ObjectMove("Trend DN-0",1,Time[st1],s1);

ObjectMove("Trend DN-0",0,Time[st2],s2);

Dn[nCurBar] = ObjectGetValueByShift("Trend DN-0",0);

//----

ObjectMove("Trend UP-0",1,Time[rt1],r1);

ObjectMove("Trend UP-0",0,Time[rt2],r2);

Up[nCurBar] = ObjectGetValueByShift("Trend UP-0",0);


Now, make the EA unwind the value you get from the line into the log and run it NOT in visual mode. Stop the test and look at the log.

I told you that you can't get values from graphical objects in the tester not in visual mode - they just don't build.

And it is difficult for you to add to the indicator a normal calculation of just one line for each value of two lines.

Well, I won't persuade you.

 
Artyom Trishkin:

Now make an EA printout of the value you get from the line into the log and run NOT in visual mode. Stop the test and look at the log.

I told you that you can't get values from graphical objects in the tester not in visual mode - they just don't build.

And it is difficult for you to add to the indicator a normal calculation of just one line for each value of two lines.

Well, I won't talk you into it.


I just don't know how to add it.

I don't understand, I'm getting errors, where to add it
 
Vyacheslav Kornev:

I just don't know how to... where to add it...

I don't get it, I have errors, where to add it

Do you know what a function is? I gave you a function. You can write it outside of the body of any indicator function and call it from the code by entering the necessary data. In the output it will give you the price of the bar you are looking for.

I wrote an article about 300 years ago on mql4.com - there is a description of how to work with the straight line equation - the function is now modified, but it hasn't changed its function that returns the price of the bar.

Here's an indicator based on that article.

 
Artyom Trishkin:

Do you know what a function is? I gave you a function. Write it outside of the body of any indicator function and call it from the code by entering the required data. In the output it will give you the price of the bar you are looking for.

I wrote an article about 300 years ago at mql4.com - there is a description of how to work with the straight line equation - the function is now modified, but it hasn't changed its function that returns the price of the bar.

Here's an indicator based on that article.


I think it makes no difference how to take the price in real trading, because the indicator and the Expert Advisor have to be attached to the chart?

Reason: