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

 

Good afternoon... I have written a simple indicator (see attached file).

In a nutshell, the essence of the indicator: the indicator consists of 3 lines:

1 line shows the difference of two MAs on Close with periods a and b (conditionally).

The 2nd line shows the difference of two MAs on Close with periods c and d (conditionally);a≠b≠c≠d.

Line 3 displays the MA of Line1 and Line2 difference, i.e. MA(Line1-Line2) with a certain period .

Question: Why is Line3 (black) shown as a straight line in the graph?


Note to the image: the upper chart shows the desired result, the lower chart shows my created indicator

Note: If someone will find some more bugs, I will be very grateful for a tip

P.S. In order not to litter the forum, thank you in advance for your feedback

Files:
aom3.mq4  12 kb
 

First, try linking the fourth non-displayable buffer ExtMapBuffer4 to the indicator buffer

SetIndexBuffer(3,ExtMapBuffer4);

because you write

   IndicatorBuffers(4);                                                 //устанавливаем общее количество всех индикаторов, участвующих в расчете всех индикаторных линий

at the beginning you describe 3 lines/buffers

by the way, then you won't need to declare it as a timeseries and check it

 

and your main mistake here

      ExtMapBuffer3[i]=iMAOnArray(ExtMapBuffer4,0,МА_ТЛ,0,Вид_МА_ТЛ,0); //рассчет значения для расчета Третьей Линии (ТЛ)

you have to go like this.

      ExtMapBuffer3[i]=iMAOnArray(ExtMapBuffer4,0,МА_ТЛ,0,Вид_МА_ТЛ,i); //рассчет значения для расчета Третьей Линии (ТЛ)
 
midorum:

First, try linking the fourth non-displayable buffer ExtMapBuffer4 to the indicator buffer

because you write

at the beginning you describe 3 lines/buffers

by the way, then you won't need to declare it as a timeseries and check it

Thanks for the reply... To finally dot the i's, I'd like to find out more about this:

1. You wrote: "First, try to associate the fourth non-mapped buffer ExtMapBuffer4 with the indicator buffer". I thought that only those arrays should be bound, which should be displayed one way or another on the Client Terminal screen, and the total number of all arrays that participate in the calculation of the custom indicator should be specified using the IndicatorBuffers function. So I must be mistaken?

2. If you don't mind, why don't you declare this array as a timeseries? Is it somehow self-organized as a timeseries?

 
7777877:

Thank you for your reply... In order to finalise this, I would like to find out one more thing:

1. You write: "first, try to connect the fourth non-mapped buffer ExtMapBuffer4 to the indicator buffer". I thought that only those arrays should be bound, which should be displayed one way or another on the Client Terminal screen, and the total number of all arrays that participate in the calculation of the custom indicator should be specified using the IndicatorBuffers function. So I was wrong?

2. If it's not difficult for you, please explain why we shouldn't declare this array as a timeseries? Is it somehow self-organising as a timeseries?

exactly so, it's automatically organized as a timeseries

you describe visible indicator buffers in the beginning

usingIndicatorBuffers() you can expand the number of automatically organized timeseries to 8 and link them to your arrays

 
Duplicating question again, deleting old one, help who can!


Ok. I'll try to give the gist of the problem, maybe someone will suggest it or help to implement it more easily.

We are working on the 1-minute chart. Let's take the minute bar (high+low/2 - average value of the bar) on the chart of 29/10/12 at 00:00 - it will be a reference point.

Then we check the deviation from this price upwards by 10 pips (each correct deviation is +1).

When we reach the 10 point deviation from the starting point - the +1 counter; and we start checking further deviations, but from the point, where we reached the 10 point deviation, and wait for the next 10 point rise in price.

For example, we get:

If (start point) + 10 pips <= price (we use all subsequent prices of bars from the starting point.) We get a counter = counter +1; and we start the starting point already from this point - (start point + 10 pips).

If (start point + 10 pips) + 10 pips <= price (all subsequent prices of bars from the reference point are used) we get counter=Counter +1; and we start from this point - (start point + 10 pips) + 10 pips.

If (start point + 10 pips + 10 pips) + 10 pips <= price (we use all subsequent prices of bars from the reference point.) we get counter=Counter +1; and we start from this point - (start point + 10 pips + 10 pips) + 10 pips.

and so on...

Until we reach a counter of 10 (counter == 10).

And every new formed 1-minute bar (high+low/2 - average value of the bar) we check for this condition and wait until the counter reaches 10 (counter == 10). Suppose two days passed, each new bar formed we checked and shifted if the conditions were correct .....

And when we reached counter =10 - we output the message that "Counter == 10". We move the starting point 2 days ahead of the initial user defined point i.e. from 29/10/12 at 00:00 to 31/10/12 at 00:00 and repeat the cycle.

Repeat the cycle and so move through the schedule.

I.e. we should take the newly formed bars and draw (high+low/2 - average value of the bar). And check for the conditions and, if they are correct, shift them as described above.

I have tried to implement it through an array, it is very confusing and gives wrong values! Help me how to implement this algorithm!
Files:
qawer.mq4  3 kb
 
merkulov.artem:

I tried to implement it through an array, it gets very confusing and gives wrong values!!! Help how to implement this algorithm!

It would be very nice if you could comment your algorithm in detail (each command and the data used), because it's very difficult to understand what is done and for what purpose

then, perhaps, you will get some help, or maybe you will find the problem yourself

 

According to the help, theSetIndexDrawBegin function indicates from which bar to start drawing. I took a standard AC indicator for testing and changed there in parameters

SetIndexDrawBegin(0,8);
   SetIndexDrawBegin(1,38);
   SetIndexDrawBegin(2,38);

to

   SetIndexDrawBegin(0,8);
   SetIndexDrawBegin(1,8);
   SetIndexDrawBegin(2,8);

Nothing has changed; it starts drawing from ... not from 8 bar to 0 bar, but from what bar it is unclear.

You can see that it's not 8...


 
hoz:

According to the help, theSetIndexDrawBegin function indicates from which bar to start drawing. I took a standard AC indicator for testing and changed there in parameters

to

Nothing has changed; it starts drawing from ... not from 8 bar to 0 bar, but from what bar it is unclear.

You can see that it's not 8...


The serial number of the bar from the beginning of the data (read "from the beginning of the chart" "from the left side"), from which the selected line of the indicator should be drawn. Drawing of the indicator is performed from left to right.
 
midorum:
Set the serial number of the bar from the beginning of the data (read "from the beginning of the chart" "from the left side of the chart"), from which the indicated indicator line should start to be drawn. The indicator is drawn from left to right.

And if I need to draw the last 30 bars for example, how should I do it then?

Reason: