[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 192

 

Please give me a hint. I don't understand why MathMax doesn't work.

The simplified version of the code (it couldn't be simpler) doesn't work either. The variable GBPUSD_High doesn't work :-( While GBPUSD_Low works fine.

P.S. I am only interested in the values on the bars from the moment the indicator is loaded.

//+-------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers3
#property indicator_color1 Black
#property indicator_color2 Gray
#property indicator_color3 Gray
//--------------------------------------------------------------------
double GBPUSD[], GBPUSD_High[], GBPUSD_Low[];
//--------------------------------------------------------------------

int init()
{
//--------------------------------------------------------------------

SetIndexBuffer(0
,GBPUSD);
SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2
);
SetIndexBuffer(1
,GBPUSD_High);
SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1
);
SetIndexBuffer(2
,GBPUSD_Low);
SetIndexStyle (2,DRAW_LINE,STYLE_DOT,1);
//--------------------------------------------------------------------

return;
}
//--------------------------------------------------------------------

int start()
{

int Counted_bars, i;
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted();
i=Bars-Counted_bars-1;

while (i>=0)
{
GBPUSD[i]=Close[i];

if (GBPUSD_Low[i]==0) GBPUSD_Low[i]=GBPUSD[i];
GBPUSD_High[i]=MathMax(GBPUSD_High[i],GBPUSD[i]);
GBPUSD_Low[i]=MathMin(GBPUSD_Low[i],GBPUSD[i]);
i--;
}
//--------------------------------------------------------------------

return;
}
//--------------------------------------------------------------------

To load, of course, to GBPUSD.

 
alderru >> :

Please give me a hint. I don't understand why MathMax doesn't work.

The simplified version of the code (it couldn't be simpler) doesn't work either. The variable GBPUSD_High doesn't work :-( While GBPUSD_Low works fine.

P.S. I am only interested in the values on the bars from the moment of indicator loading.

Of course, I have to load it to GBPUSD.

MathMax has nothing to do with it. Variant:

while ( i>=0)
{
GBPUSD[ i]=Close[ i];
GBPUSD_High[ i]=High  [ i];
GBPUSD_Low[ i]=Low[ i];

//if (GBPUSD_Low[i]==0) GBPUSD_Low[i]=GBPUSD[i];

GBPUSD_High[ i]=MathMax( GBPUSD_High[ i], GBPUSD[ i]);
GBPUSD_Low[ i]=MathMin( GBPUSD_Low[ i], GBPUSD[ i]);
i--;
}
 
tmp.0 >> :

>>MathMax has nothing to do with it.

Exactly! So clearly High is always greater than or equal to Close, MathMin is the same ;)

 
OneDepo писал(а) >>

Exactly! So clearly High is always greater than or equal to Close, MathMin is the same ;)

As an example, I purposely gave the calculation of already known values. In the original, I'm looking for maximum and minimum on a bar of a completely different variable. When the indicator is drawn, the curve of the variable is redrawn while the bar is being formed, of course. I am looking for the boundary points.

I don't understand why the MathMax function doesn't work itself. MathMin works well; GBPUSD_Low curve is drawn...

In terms of programming grammar, do you have any remarks?

Please, install the indicator, tell me what is wrong, why GBPUSD_High is not calculated.

 
alderru >> :

As an example, I have purposely given the calculation of already known values. In the originals, I look for the maximum and minimum on a bar of a completely different variable. When the indicator is displayed, the curve of the variable is redrawn, of course, during the bar formation. I am looking for the boundary points.

I don't understand why the MathMax function itself doesn't work.

Do you have any remarks from programming graphical point of view?

Install the indicator and tell me what is wrong here, why GBPUSD_High is not calculated.

Don't be fooled. paste this into your favourite part of the code:

Print (GBPUSD_High[i],":",GBPUSD_Low[i],":",GBPUSD[i]); 
and you will have an epiphany in the "experts" tab.
 
tmp.0 писал(а) >>

Don't be fooled. you put this in the place where you like the code:

and you will have an epiphany in the "experts" tab.

So what...

There is no epiphany. Print prints only two values, just as it displays the indicator. What about the third?

Have you even tried to do what you advise?

 
Next question, please :)
 
tmp.0 писал(а) >>
Next question, please :)

Very clever.

Thanks for the "help".

 
alderru >> :

Very clever.

Thanks for the 'help'.

You have already been given the answer above. The reason is using an unassigned value in the right part of the assignment operator. What does GBPUSD_High[i] equal in the string

GBPUSD_High[i]=MathMax(GBPUSD_High[i],GBPUSD[i]);

You've been shown an option to correct the situation as well. Leave the irony behind.


 
OneDepo писал(а) >>

The reason is the use of an unassigned value in the right hand side of the assignment operator.

So declaring indicator buffers does not mean that cell values are zero. Right?

Therefore, MathMax isn't calculated as one of the values being compared (namely, GBPUSD_High) has no value (at all, not even zero).

I see. Thanks OneDepo.

I apologise for confusing everyone with my simplification (pun intended). As I already mentioned, I am not interested in the value of High quotes, I am interested in the maximum value on the bar of my own function, the curve of which the indicator successfully draws and re-recurses while it is forming the bar. This is the range of indicator re-drawing during the bar I was interested in.

I will think about it.

P.S. But why MathMin is considered without problems, the conditions are equal and are declared the same?

P.S. Somewhere I am very blunt. I cannot do it. Help, please.