StockWiz 5 Formulas

 

Example2: Simple graph

Description: The formula below displays a graph with CLOSE prices, 20 day moving average and the corresponding VOLUME.

 


// 
// Sample graph formula 
//  
CLOSE   = LOAD(_TICKER,CLOSE) 
ICLOSE  = INTERPOLATE(CLOSE) 
VOLUME  = LOAD(_TICKER,VOLUME) 
MA20    = MOVAVG(ICLOSE,20)  
 
GRAPHTITLE(_TICKER) 
GRAPHAREA(75,25,0,0,0,0) 
GRAPHLINE(Axis1,CLOSE,RED) 
GRAPHLINE(Axis1,MA20,BLUE) 
GRAPHBAR(Axis2,VOLUME,GREEN) 
 

 

Here is a snapshot of the graph:

 

 SampleGraph.jpg
 
Please note how the moving average (the blue line) starts on the 20th point. This is because for the first 19 values there is not enough data to calculate the 20 day moving average. The way around this is to use the RANGE function twice. The RANGE function specifies the range of the working data. If you do not use the the RANGE function, the formula defaults to the date range specified at the bottom of StockWiz 5.
 
 DefaultDateRange.jpg
 
The reason you need to use the RANGE function twice, is that the first time you use a range which has an extra 20 days. The second time the RANGE function will be called with the regular range and therefore remove the first 20 points.
 
Here is the formula:
 
//
// Sample graph formula
//
RANGE(-70,_LASTDATE)
ICLOSE  = INTERPOLATE(CLOSE)
VOLUME  = LOAD(_TICKER,VOLUME)
MA20    = MOVAVG(ICLOSE,20)

RANGE(-50,_LASTDATE)
GRAPHTITLE(_TICKER)
GRAPHAREA(75,25,0,0,0,0)
GRAPHLINE(Axis1,CLOSE,RED)
GRAPHLINE(Axis1,MA20,BLUE)
GRAPHBAR(Axis2,VOLUME,GREEN)
 
 
Here is the new graph:
 
SampleGraphWithRANGE.jpg