Find out Highest High and Lowest Low value from a specific date Range

Have you read this thread completely before posting? Have you noticed the code tags animation in first post? If so then why not applying it in your post? It is mandatory rule to apply code tags if inserting code to a post.


As for the code...

you do equality check (via == operator). So if a date does not exists then it will fail.
So you may use LookUp function to search for nearest predecessor/successor in such cases.

_SECTION_BEGIN( "Find High Low" );
/// @link https://forum.amibroker.com/t/find-out-highest-high-and-lowest-low-value-from-a-specific-date-range/14356
dt = DateTime();
//
StartDate = _DT("2019-07-01");
EndDate = _DT("2019-07-14");
StartBar = dt == Lookup( dt, StartDate, 1);
EndBar = dt == Lookup( dt, EndDate, -1);
//
myH = ValueWhen( EndBar, HighestSince( StartBar, High ) );
myL = ValueWhen( EndBar, LowestSince( StartBar, Low ) );
//
Plot( C, "Price", colorDefault, styleBar );
Plot( myH, "myH", colorGreen );
Plot( myL, "myL", colorRed );
//
Title = " Highest High - " + myH + " Lowest Low - " + myL;
_SECTION_END();

Note also: "your" code will start output at looked up EndBar (since that's what is told to AB by the program).

8

4 Likes