Percent Rank coding

Questions about MultiCharts and user contributed studies.
LMC1
Posts: 50
Joined: 28 Apr 2013
Has thanked: 29 times
Been thanked: 1 time

Percent Rank coding

Postby LMC1 » 24 Apr 2021

Hi,

For a look back period of 200 days, I want to know the percent rank of current day's return from yesterday.
I tried with these codes but don't know how to set the three inputs for the PercentRankArray function.
Anyone can help please? Thanks.

Array: intrabarpersist DailyReturn[199](0);
Inputs: Len(200);
vars: counter(0), PctRank(0);

for counter = 0 downto -199 begin
DailyReturn[counter] = percentChange(C,1)[counter];
end;

PctRank = PercentRankArray(PriceValueToRank,PriceValueArray,Size);

plot1(PctRank,"PctRank");

tpredictor
Posts: 108
Joined: 05 Mar 2014
Has thanked: 1 time
Been thanked: 12 times

Re: Percent Rank coding

Postby tpredictor » 24 Apr 2021

Are you trying to compare the percent rank of today vs yesterday? Are you sure you want to use percent rank? You may want to review the meaning of percent rank. The inputs are value to rank, the collection to be ranked against, and the lookback period. If I understand you right, it would look something like this. You don't need to use the array-- you can just use the series function.

Value10 = Close-Close[1];

Rank = PercentRank(Value10, Value10,200);

Alternatively, if you don't want to use a lookback of 200 days, start a counter and use it like this:

Counter = IFF(Counter <= 200, Counter+1, 200);

LMC1
Posts: 50
Joined: 28 Apr 2013
Has thanked: 29 times
Been thanked: 1 time

Re: Percent Rank coding

Postby LMC1 » 24 Apr 2021

Hi tpredictor,

Thanks for your prompt response.
The One-day return I am thinking is (C - C[1]) / C[1].
I want to know the Percent Rank of today's one-day return, when compare to all of the one-day return in the last 199 days.

Thanks

tpredictor
Posts: 108
Joined: 05 Mar 2014
Has thanked: 1 time
Been thanked: 12 times

Re: Percent Rank coding

Postby tpredictor » 24 Apr 2021

You should be able to use the example I gave you just replacing out the value10 with your series.

LMC1
Posts: 50
Joined: 28 Apr 2013
Has thanked: 29 times
Been thanked: 1 time

Re: Percent Rank coding

Postby LMC1 » 24 Apr 2021

Hi t,

Thanks for your kind help.
Have a nice week end.


Return to “MultiCharts”