[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Normalizing two unrelated data arrays



PureBytes Links

Trading Reference Links

Jim, this is a very common T/A dilema: how to compare two unrelated 
data plots with different scales?

Before you 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:


===============================
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<--------------------------


jose '-)
http://www.metastocktools.com




--- In equismetastock@xxxxxxxxxxxxxxx, stinkerstock <no_reply@xxxx> 
wrote:
>
> Hi everybody.
> 
> I wonder if someone could help me with a coding problem.  I like 
> using williams a/d and I like to superimpose the indicator over a 
> security I'm looking at.  
> 
> My question is this: I would like to code for a new indicator that 
> measures the distance (plus or minus) between Williams a/d and the 
> underlying security when superimposed on the security.  The problem 
> is that you can't just take a close and add it to the value of 
> Williams because oftentimes the indicator value is a minus figure 
> whereas the indicator, when superimposed on the security, is showing 
> positive strength vs. that security.
> 
> As an aside, here's the code for Williams a/d:
> 
> TrueRangeHigh:=Max( Ref(CLOSE,-1), HIGH );
> TrueRangeLow:=Min( Ref(CLOSE,-1), LOW );
> Cum(If(C > Ref(C,-1),C-TrueRangeLow, If(C < Ref(C,-1),C-
> TrueRangeHigh,0))).
> 
> Thanks in advance for any assistance.
> 
> Jim









------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/