HighestSince and LowestSince , How to use the third parameter and result of it?

Hi,

I try to apply the third parameter in HighestSince or LowestSince, so far I don't understand to use it yet. As far as HighestSince function is concerned, The third parameter almost ignores for using.
https://forum.amibroker.com/t/highest-and-lowest-price/7083/2

The below show sample code.

Filter=1;

BuySignal_RSIx=Cross(RSI(15),60);


AddColumn(RSI(15),"RSI(60)",1.2);


// no the thid paramter
HighestOfDay = HighestSince(BuySignal_RSIx,c); 
AddColumn(HighestOfDay,"HighestOfDay",1.2);

// Nth = 2
HighestOfDay_plus1 = HighestSince(BuySignal_RSIx,C,2); 
AddColumn( HighestOfDay_plus1,"HighestOfDay_plus1",1.2);

//Nth = -2
HighestOfDay_plus2 = HighestSince(BuySignal_RSIx,c,-2);
AddColumn(  HighestOfDay_plus2,"HighestOfDay_prev1",1.2);


1

Please clarify how to apply it. it would be better if anyone picks up any good sample.

Thank you in advance.

Pongthorn

@technqvi, IMO, this is the kind of things that you may probably better understand studying with a lot of attention the result of an exploration:

immagine

Corresponding code:

Filter = 1;
BuySignal_RSIx = Cross( RSI( 15 ), 60 );
AddColumn( RSI( 15 ), "RSI(60)", 1.2 );
AddColumn( IIf(BuySignal_RSIx, 1, Null), "Signal");
AddColumn( IIf(BuySignal_RSIx, Cum(BuySignal_RSIx), Null), "Sig count", 1);
AddColumn( C, "Close");
// no the thid paramter == 1
HighestOfDay = HighestSince( BuySignal_RSIx, C );
AddColumn( HighestOfDay, "HighestOfDay - 1st", 1.2 );
// Find the Highest value since the 3rd away buy signal - Nth = 3
HighestOfDay_3rd = HighestSince( BuySignal_RSIx, C, 3 );
AddColumn( HighestOfDay_3rd, "HighestOfDay - 3rd", 1.2 );
SetSortColumns(-2);

Note that result are sorted to show the most recent bars at top.
To understand what happens, please, read the column values from the bottom upward.

In the "Highest -1st" column you'll see the value change at each signal since you are requesting the highest ARRAY value since EXPRESSION was true on the most recent occurrence (1 is the default parameter and means the last occurrence).

Until the next signal (that for convenience I also numbered progressively), the highest value can change again multiple times (each time a new higher Close is encountered) and the highest found value is retained until the next higher occurrence or a new signal.

If you look at the "HighestOfDay - 3rd" the value does not necessarily change at the same points: it only happens when there is a new higher Close compared to the previous Close values comprised in the range defined by 3 signals.

In particular, look at the values between signal 14 and the row below signal 17: the highest value 7682.75 is retained for multiple bars and was set between signal 14 and 15.

But more than my somewhat crippled description, you should study the results comparing the highest columns values with the "Close" column values, evaluating the position of the signals (that correspond to the expression/condition to be met) until you completely figure it out.

I hope some else will provide a better example and explication since the same logic is used in many other similar functions.

6 Likes