How to code new high for an indicator

 

Hello,

can someone please tell me the code for a new high / Low of an indicator. 

For understanding see attached picture.

Thank you so much.

 
Mike Michel:

Hello,

can someone please tell me the code for a new high / Low of an indicator. 

For understanding see attached picture.

Thank you so much.

Just remember the previous high/low value and compare it to current
 
Navdeep Singh #:
Just remember the previous high/low value and compare it to current


Hi Navdeep Singh,

thanks for your comment

I do not understand the logic how I  set the new low, because the next low must not be a new low.  And when I have to set a low value to "empty" ? because a some point new low cant go deeper ...........

I tried a lot of codes, but it doesn work as I want.

Please can you help ?


2 of my  examples:


***

 
Mike Michel #:


Hi Navdeep Singh,

thanks for your comment

I do not understand the logic how I  set the new low, because the next low must not be a new low.  And when I have to set a low value to "empty" ? because a some point new low cant go deeper ...........

I tried a lot of codes, but it doesn work as I want.

Please can you help ?


2 of my  examples:


***

Use    Code button to add your code correctly

You could try using array functions (ArrayMaximum and ArrayMinimum). That is one way to achieve index of the last highest lowest values for n period

https://docs.mql4.com/array

Array Functions - MQL4 Reference
Array Functions - MQL4 Reference
  • docs.mql4.com
Array Functions - MQL4 Reference
Reason: