Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
I often get asked something along this line of thinking:
Quote:My price chart is out of scale when I apply the MACD to it - how can I get MACD()/price crossover signals?
Before we can apply any relative comparisons between a chart and unscaled indicator, both plots need to be normalized to a common scale.
There are two easy ways to normalize plots to 0~100%: using historical High/Lows, or x periods' High/Low:
[code:1:c7b2f8da76]
===============================
Normalization - Price/Indicator
===============================
---8<--------------------------
{ Normalizes two data array plots to within
0~100% boundaries, and allows direct
comparisons between the two plots. }
{©Copyright 2004 Jose Silva
For personal use only.
http://www.metastocktools.com }
{ Choose between normalizing lookback periods
or historical High/Low normalization }
pds:=Input("Normalizing lookback periods (1= historical Hi/Lo)",1,2600,126);
{ Plot 1: Price section }
PriceX:=C;
{ Choose x pds or historical Price High/Low }
Hi:=If(pds>1,HHV(PriceX,pds),Highest(PriceX));
Lo:=If(pds>1,LLV(PriceX,pds),Lowest(PriceX));
{ Price normalized to 0~100% }
PriceNorm:=(PriceX-Lo)/Max(Hi-Lo,.000001)*100;
{ Plot 2: Indicator/Oscillator section }
IndX:=MACD();
{ Choose x pds or historical Indicator High/Low}
Hi:=If(pds>1,HHV(IndX,pds),Highest(IndX));
Lo:=If(pds>1,LLV(IndX,pds),Lowest(IndX));
{ Indicator normalized to 0~100% }
IndicatorNorm:=(IndX-Lo)/Max(Hi-Lo,.000001)*100;
{ Plot in own window }
PriceNorm;IndicatorNorm
---8<--------------------------
[/code:1:c7b2f8da76]
jose '-)
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.