PureBytes Links
Trading Reference Links
|
If I understand you correctly, you want to take variable source
ranges of values and map them to a static destination range. This is
a powerful way to equally compare a broad range of indicators, based
on the historical source range of each indicator.
There's probably an easier way, but this is how I do it with my own
Visual Basic programs. It shouldn't be too difficult to translate
into Amibroker.
First define the min and max of your source and destination ranges.
The SOURCE range, for example, could be the min and max of TRIX
values over the past year. We'll call them S_MIN and S_MAX. The
DESTINATION range is the range you want to map everything to, or
D_MIN and D_MAX.
D_MIN = 0
D_MAX = 100
S_MIN = -20 'get the minimum historical value of the indicator
S_MAX = 60 ' max value of indicator
MY_VALUE = 30 ' this is the value you want to map, for example the
latest TRIX value.
Calculate the difference between D_MAX and S_MAX.
DIFF = 0
if D_MAX <> S_MAX then DIFF = D_MAX - S_MAX
Next we'll get the ranges of each...
D_RANGE = D_MAX - D_MIN
S_RANGE = S_MAX - S_MIN
Percentage difference between the ranges...
RANGE_DIFF = 0
if D_RANGE<>S_RANGE then RANGE_DIFF = 100/(S_RANGE/(D_RANGE-S_RANGE))
We now have all the info we need to calculate the mapping.
NEW_VALUE = INT((MY_VALUE+DIFF)+((MY_VALUE+DIFF)*
(RANGE_DIFF/100)-RANGE_DIFF))
I hope someone finds this useful! Please report here if you try it.
Brian
http://www.tickerank.com/
Steve Davis wrote:
> Here is a question for the mathematically inclined.
>
> Suppose I have an indicator, for example TRIX, that has a different
> range of values for different stocks.
>
> How can it be mathematically transformed to force it into the same
> range, say 0-100, for all stocks?
>
> Thanks in advance,
> -Steve
|