StockWiz 5 Formulas

 

Example1: Calculate Median Value

Description: The Median value is defined as the average of the High and Low prices of the day. Some take this to be a better representation of the day's price.

 


//
// Calculate Median values
//

// Load prices for current company

HIGH   = LOAD(_TICKER,HIGH)
LOW    = LOAD(_TICKER,LOW)
CLOSE  = LOAD(_TICKER,CLOSE)
VOLUME = LOAD(_TICKER,VOLUME)

// Interpolate for any missing values 

ICLOSE = INTERPOLATE(CLOSE)
IHIGH  = INTERPOLATE(HIGH)
ILOW   = INTERPOLATE(LOW)

// Calculate median value for all entries in the vector

MEDIAN = LOOPCALC(  (IHIGH(i)+ILOW(i)) / 2.0 )

// Display graph

GRAPHTITLE(_TICKER)

// Graph can have up to 6 "stack-up" charts
// We only use the first two and we give the first chart
// 75% of the area

GRAPHAREA(75,25,0,0,0,0)

// We now assign vectors to each chart (referred to as axis)

GRAPHLINE(Axis1,CLOSE,RED)
GRAPHLINE(Axis1,MEDIAN,BLUE)
GRAPHBAR(Axis2,VOLUME,GREEN)

Here is a image of the output:

MedianPriceChart.gif