Module Table of Contents

Go to Function Index

  • MV_AVG_R.C Simple and exponential style moving average routines. Plus routines to lag or lead an indicator series.
  • AMVAVG_R.C Adaptive moving average routines based on Perry Kaufman's 03/93 Futures article.
  • WMVAVG_R.C Weighted moving average routines.
  • STDDEV_R.C Standard deviation routines.
  • LINREG_R.C Least-squares and best-fit linear regression and time series line regression indicator routines.
  • DFQREG_R.C Dual frequency trigonometric regression routines.
  • MACD_R.C Moving Average Convergence / Divergence and Moving Average Convergence / Divergence Histogram routines.
  • BBAND_R.C Bollinger Band indicator routines.
  • RSI_R.C Relative Strength Index routines.
  • STOC_R.C Stochastics and Williams' %R routines prototypes and typedefs.
  • WLDPAR_R.C Welles Wilder's Parabolic Time/Price indicator routines.
  • RWI_R.C Mike Poulos' Random Walk Index indicator routines.
  • FIBPRJ_R.C Routines for calculating Fibonacci price retrace and expansion projections.
  • CSTM_IND.C This module contains the indicator routines for CSTM_RPT.
  • CSTM2IND.C This module contains more of the indicator routines for CSTM_RPT.
  • DTFL_ACC.C Standardized data file access routines to support Computrac/Metastock, CSI and ASCII data files.
  • STDBPATH.C The standard database path routines.
  • WRT_DT_R.C Routines to support creation, writing & updating of CompuTrac & MetaStock datafiles.
  • MEMCPTDT.C These are a few routines layered on top of the standard datafile access routines to support memory caching of the master file info.
  • OUTDEV_R.C The standard output_device support routines.
  • STD_CODE.C This module is the home for all user-interface, standard product routines.
  • GEN_UTL.C A few utility routines that don't need a whole module.
  • PRC_CNFG.C A set of routines to read an ASCII configuration file and process it's data and store the info back in the caller's main() module.
  • GETARGS.C Command line argument processor.
  • ERR_MSGS.C Error msgs and constants for the file access and cmd line configuration routines.
  • C_DATE_R.C Convert and validate DATE Routines.
  • J_DATE_R.C Julian date routines.
  • MRK_DAYR.C These routines will support hidden holiday tracking providing a way to check a julian date to determine if the market will be open.
  • DOS_TIME.C A collection of MSDOS time and date routines.
  • DOS_CODE.C This module contains various low level DOS disk interface routines.
  • CNVTBOND.C Conversion routines for handling T-Bond data.
  • UTLSTR_R.C A collection of useful string manipulation routines (they all expect NULL terminated strs).
  • S_PARSER.C A couple very simple ANSI C parse and identify routines.
  • MY_DIR.C A few wrapped MSDOS directory functions.
  • GRX.C This module contains the EGA mode graphics charting subsystem.
  • SM_GRX.C This is the C code hacked into a mini graphics library from the Aztec library.
  • SM_GRX2.ASM This is the asm code hacked into a mini graphics library from the Aztec library.
  • VECT_TXT.ASM A procedure to write a str to a graphics display using a stroked font set.
  • MSBIN2IE.ASM 2 routines to convert a Microsoft 4 byte float to a IEEE 4 byte float and back.
  • LOWLEVEL.ASM Here are the low level assembler routines.
  • VIDEO_IO.ASM A few video string display routines.
  • LMACROS.INC Some macros to make assembler coding easy.
  • CSTM_RPT.C A program to easily run multiple indicators and systems in parallel against a data set and then generate a custom report for the user.
  • CSTM2RPT.C ...
  • CSTM3RPT.C ...
  • SNAPSHOT.C A Q & D program to load 1 to 4 charts and (and possible indicators) maybe then call the resident EPSON driver for a snapshot suitable for printing with G_RPT.
  • DUMP_CDT.C A Q & D to dump CSI & Computrac master and data files to stdout to see what I've got.
  • ANAL_CYC.C A Q & D program to read a file of ASCII cycles and track where a market is in relation to them.
  • NICESHEL.C A nice empty shell program to start coding from.
  • PPRINT.CPP A Q & D program to use the PRINTER and SPOOLER objects to Pretty Print C source.
  • PRINTER.CPP Method definitions for the Printer object.
  • SPOOLER.CPP Method definitions for the Spooler object.

  • MV_AVG_R.C - MoVing AVeraGe Routines

    ANSI C simple and exponential style moving average routines. This module also contains a routine to support leading (what Joe DiNapoli calls Key Of The Day) and lagging a moving average array or a display indicator array.

    Let's take this opportunity to show an overview to the stand-alone indicator modules. The stand-alone indicator modules are designed to be called by the user with the user provided data where as the CSTM_RPT indicator routines are called by CSTM_RPT for the user. The standalone modules all have a consistant user interface.

    Each indicator will have its own typedef-ed data structure which will contain all the internal vars necessary to calculate the indicator. This data structure will also handle caching of the raw input data stream if this is necessary for the calculations. There will be 2 routines for allocation and deallocation for each indicator structure. There will also be a reset routine to reset the internal vars for a new data series. These routines will be of the form -

    ???     *new_???_struct() ; // this call may have arguments for some inds.
    void    free_???_struct( ??? *ind_ptr ) ;
    void    reset_???_struct( ??? *ind_ptr ) ; 
    
    or for example -

    typedef struct {                // Simple moving averages
        float   sma ;
        int     ma_length ;
        int     data_idx ;
        int     enough_data ;
        float   *data ;             // internal data cache
    }   SMA ;
    

    SMA *new_sma_struct( int ma_length ) ; void free_sma_struct( SMA *sma_ptr ) ; void reset_sma_struct( SMA *sma_ptr ) ;

    There will also be 2 routines that you can call to get an indicator calculated for you. The first way is with an update_???_struct() call. The form expects your program to handle stepping through each value of the data series but it allows you to calculate an indicator off of any data series not just normal DATA_REC data. Of course some indicators do require normal DATA_REC (like a stochastic which needs high, low & close to calc). Once the indicator is up to speed the enough_data field will be set to TRUE and the indicator can be used. For example -

    void update_sma_struct( SMA *sma_ptr , float new_data ) ;

    // given - float *data_array ; // loaded with some data

    sma_ptr = new_sma_struct( 20 ) ; for( i = 0 ; i < max_data_cnt ; i++ ) {
    update_sma_struct( sma_ptr , data_array[ i ] ) ;
    if( sma_ptr->enough_data )
    printf( "SMA = %f \n" , sma_ptr->sma ) ; }

    The other form directly calculates any indicator suitable for charting. This means that the returned indicator also contains some magic cookie values for the graphics subsystem - IND_VAL_INVALID which means that the indicator is not up to speed and so graphics subsystem suppresses the plot of that data point. The indicator will either be simple float arrays for simple indicators like SMA's or typedef-ed structures for more complicated indicator systems like Bollinger Bands. These routines expect to given a DATA_REC data series and a which field to use flag. The calc routine will handle the allocation & deallocation of the low-level indicator structure but now your program will be responsible for ownership of the higher level indicator display structure.

    void calc_sma_ind( DATA_REC *data_ptr ,
    int data_cnt , int which_field , float *inds , int ma_length ) ;

    // given - DATA_REC *data_array // loaded with 50 bars of some data // and a - float *sma_20_inds ;

    sma_20_inds = my_calloc( sizeof( float ) * 50 ) ; calc_sma_ind( data_array , 50 , DF_CLOSE , sma_20_inds , 20 ) ;

    // that's all you need to do and then you can grfx = draw_cmd_chart( GRX_FULL__SCR , GRX_FG_FLT_DATA , 50 , sma_20_inds
    , "SMA 20" ) ; // to display it

    And here is a more complicated example -

    typedef struct { // Bollinger Bands indicator display structure
    float *upper_band ;
    float *mean ;
    float *lower_band ;
    float *percent_b ; } BBAND_IND ;

    bband_ptr = new_bband_ind_struct( 20 ) calc_bband_ind( data_array , 50 , DF_CLOSE , sma_20_inds , 20 , 2.0 ) ;

    // that's all you need to do and then you can grfx = draw_cmd_chart( GRX_FULL_SCR , GRX_FG_DATA_REC , 50 , data_array ,
    "Some Data with BBands" ) ; overlay_line_plot( grfx , bband_ptr->upper_band , MA1_COLOR ) ; overlay_line_plot( grfx , bband_ptr->mean , MA1_COLOR ) ; overlay_line_plot( grfx , bband_ptr->lower_band , MA1_COLOR ) ; free_bband_ind_struct( bband_ptr ) ;


    Function new_sma_struct
    Include file MV_AVG_R.H
    Prototype SMA *new_sma_struct( int ma_length )
    Remarks Allocate, initialize and return a virgin simple moving average structure.


    Function reset_sma_struct
    Include file MV_AVG_R.H
    Prototype void reset_sma_struct( SMA *sma_ptr )
    Remarks Reset a SMA data structure for a new data series.


    Function update_sma_struct
    Include file MV_AVG_R.H
    Prototype void update_sma_struct( SMA *sma_ptr , float new_data )
    Remarks Update the caller's SMA with the new data. Once we have collected enough data to calc the SMA, sma_ptr->enough_data will be set to TRUE and sma_ptr->sma can be used.


    Function free_sma_struct
    Include file MV_AVG_R.H
    Prototype void free_sma_struct( SMA *sma_ptr )
    Remarks Return the SMA and its sub-structure memory to the system.


    Function calc_sma_ind
    Include file MV_AVG_R.H
    Prototype void calc_sma_ind( DATA_REC *data_ptr , int data_cnt , int which_field , float *inds , int ma_length )
    Remarks Calculate a simple moving average indicator of ma_length for the requested field for the DATA_REC data series. The indicator will be built in the caller's data area inds.


    Function new_ema_struct
    Include file MV_AVG_R.H
    Prototype EMA *new_ema_struct( int ma_length )
    Remarks Allocate, initialize and return a virgin exponential moving average structure.


    Function reset_ema_struct
    Include file MV_AVG_R.H
    Prototype void reset_ema_struct( EMA *ema_ptr )
    Remarks Reset a EMA data structure for a new data series.


    Function update_ema_struct
    Include file MV_AVG_R.H
    Prototype void update_ema_struct( EMA *ema_ptr , float new_data )
    Remarks Update the caller's EMA with the new data. Once we have collected enough data for the EMA to be up to speed, ema_ptr->enough_data will be set to TRUE. Since this is a EMA the var ema_ptr->ema will always have a value.


    Function calc_ema_ind
    Include file MV_AVG_R.H
    Prototype void calc_ema_ind( DATA_REC *data_ptr , int data_cnt , int which_field , float *inds , int ma_length )
    Remarks Calculate a exponential moving average indicator of ma_length for the requested field for the DATA_REC data series. The indicator will be built in the caller's data area inds.


    Function calc_ema_coeff
    Include file MV_AVG_R.H
    Prototype void calc_ema_coeff( int ma_length , float *coeff_a , float *coeff_b )
    Remarks Calculate the coefficients for a exponential moving average. They would be used as -> new_ema = ( new_data * coeff_a ) + ( old_ema * coeff_b ).


    Function shift_moving_average
    Include file MV_AVG_R.H
    Prototype void shift_moving_average( int shift_offset , int data_cnt , float *inds )
    Remarks This routine will take a array of floats (which can be either moving averages or other indicators) and will shift data_cnt items by the shift_offset amount. If the shift_offset is positive the indicator series will be shifted forward in time yielding a leading indicator else if negative the series will be shift backwards in time yeilding a lagging indicator. The cells that are freed up by the shift will be set to the indicator magic cookie display value IND_VAL_INVALID so they will not be plotted. It is the caller's responsibility to insure the float array has enough room for the positive shifted values and that his count of indicators in the array are updated for the shift, for negative shifts the first shift_offset number of data items will be dropped into the bit bucket.


    Table of Contents Function Index

    AMVAVG_R.C - Adaptive MoVing AVeraGe Routines

    ANSI C adaptive moving average routines based on Perry Kaufman's 03/93 Futures article.


    Function new_ama_struct
    Include file AMVAVG_R.H
    Prototype AMA *new_ama_struct( int ma_length )
    Remarks Allocate, initialize and return a virgin adaptive moving average structure.


    Function reset_ama_struct
    Include file AMVAVG_R.H
    Prototype void reset_ama_struct( AMA *ama_ptr )
    Remarks Reset a AMA data structure for a new data series.


    Function update_ama_struct
    Include file AMVAVG_R.H
    Prototype void update_ama_struct( AMA *ama_ptr , float new_data )
    Remarks Update the caller's AMA with the new data. Once we have collected enough data to calc the AMA, ama_ptr->enough_data will be set to TRUE and ama_ptr->ama can be used.


    Function free_ama_struct
    Include file AMVAVG_R.H
    Prototype void free_ama_struct( AMA *ama_ptr )
    Remarks Return the AMA and its sub-structure memory to the system.


    Function new_ama_ind_struct
    Include file AMVAVG_R.H
    Prototype AMA_IND *new_ama_ind_struct( int data_cnt )
    Remarks Allocate, and return a virgin adaptive moving average indicator display structure for data_cnt items.


    Function free_ama_ind_struct
    Include file AMVAVG_R.H
    Prototype void free_ama_ind_struct( AMA_IND *ama_ptr )
    Remarks Return the AMA indicator display structure and its sub-structure memory to the system.


    Function calc_ama_ind
    Include file AMVAVG_R.H
    Prototype void calc_ama_ind( DATA_REC *data_ptr , int data_cnt , int which_field , AMA_IND *inds , int ma_length )
    Remarks Calculate a set adaptive moving average indicators for the requested field of the DATA_REC data series. The indicators will be built in the caller's AMA_IND indicator display structure inds.


    Table of Contents Function Index

    WMVAVG_R.C - Weighted MoVing AVeraGe Routines

    ANSI C weighted moving average routines.


    Function new_wma_struct
    Include file WMVAVG_R.H
    Prototype WMA *new_wma_struct( int ma_length )
    Remarks Allocate, initialize and return a virgin weighted moving average structure.


    Function reset_wma_struct
    Include file WMVAVG_R.H
    Prototype void reset_wma_struct( WMA *wma_ptr )
    Remarks Reset a WMA data structure for a new data series.


    Function update_wma_struct
    Include file WMVAVG_R.H
    Prototype void update_wma_struct( WMA *wma_ptr , float new_data )
    Remarks Update the caller's WMA with the new data. Once we have collected enough data to calc the WMA, wma_ptr->enough_data will be set to TRUE and wma_ptr->wma can be used.


    Function free_wma_struct
    Include file WMVAVG_R.H
    Prototype void free_wma_struct( WMA *wma_ptr )
    Remarks Return the WMA and its sub-structure memory to the system.


    Function calc_wma_ind
    Include file WMVAVG_R.H
    Prototype void calc_wma_ind( DATA_REC *data_ptr , int data_cnt , int which_field , float *inds , int ma_length )
    Remarks Calculate a weighted moving average indicator of ma_length for the requested field for the DATA_REC data series. The indicator will be built in the caller's data area inds.


    Table of Contents Function Index

    STDDEV_R.C - STanDard DEViation Routines

    ANSI C standard deviation routines.


    Function new_stddev_struct
    Include file STDDEV_R.H
    Prototype STDDEV *new_stddev_struct( int stddev_length )
    Remarks Allocate, initialize and return a virgin standard deviation structure.


    Function reset_stddev_struct
    Include file STDDEV_R.H
    Prototype void reset_stddev_struct( STDDEV *stddev_ptr )
    Remarks Reset a standard deviation data structure for a new data series.


    Function update_stddev_struct
    Include file STDDEV_R.H
    Prototype void update_stddev_struct( STDDEV *stddev_ptr , float new_data )
    Remarks Calculate a N-population standard deviation (as well as a few of other common stat values (min, max, SMA, EMA, summ & variance) ). Once we have collected enough data to calc the STDDEV, stddev_ptr->enough_data will be set to TRUE and stddev_ptr->std_dev can be used.


    Function free_stddev_struct
    Include file STDDEV_R.H
    Prototype void free_stddev_struct( STDDEV *stddev_ptr )
    Remarks Return the STDDEV and its sub-structure memory to the system.


    Table of Contents Function Index

    LINREG_R.C - LINear REGression Routines

    ANSI C least-squares and best-fit linear regression and time series line regression indicator routines.


    Function new_linreg_struct
    Include file LINREG_R.H
    Prototype LINREG *new_linreg_struct( void )
    Remarks Allocate and return a virgin linear regression structure.


    Function calc_linreg
    Include file LINREG_R.H
    Prototype void calc_linreg( LINREG *linreg , int data_max , float *data_ptr )
    Remarks Calculate a least-squares linear regression on the supplied data. The parameter data_ptr is a pointer to a data series that is data_max items long. Least-squares regression uses a sequential integer count as the x-axis (or as the independent variable) to generate the projection of the dependent variable (the inputed price series). So this means least squares uses time (or bar periods if you prefer) to project prices.


    Function calc_best_fit_linreg
    Include file LINREG_R.H
    Prototype void calc_best_fit_linreg( LINREG *linreg , int data_max , float *data_ptr_ind , float *data_ptr_dep )
    Remarks Calculate a best-fit linear regression on the supplied data. The parameters data_ptr_ind & data_ptr_dep are pointers to data series that are data_max items long. A best-fit linear regression uses one data series as the x-axis (or as the independent variable) to generate the projection of the dependent variable. This means best-fit can be used to project the prices of one series given the past relationship of 2 prices series. For example given the past prices of corn & soybeans - calc the regression, then given a new price for corn you could project a new price for beans.


    Function finish_regression_calcs
    Include file LINREG_R.H
    Prototype void finish_regression_calcs( LINREG *linreg , int data_max , float *data_ptr , double sum_x , double sum_y , double sum_xy , double sum_x_sqed , double sum_y_sqed )
    Remarks This routine actually does the regression calcs after the input data has been processed (for both regression styles).


    Function calc_new_price_with_linreg
    Include file LINREG_R.H
    Prototype float calc_new_price_with_linreg( LINREG *linreg , float cur_dep_data )
    Remarks Once you have calculated a regression on a data series, use this routine to project the new data from the regression. This routine can use the regression output from either least-squares or best-fit regression. Just pass a bar number as the current dependent data value or pass an actual price for a best_fit projection.


    Function detrend_data_series
    Include file LINREG_R.H
    Prototype void detrend_data_series( int data_cnt , float *data_ptr )
    Remarks Use a least-squares regression to remove the trend from a data series.


    Function restore_trend_2_data_series
    Include file LINREG_R.H
    Prototype void restore_trend_2_data_series( LINREG *linreg , int data_cnt , float *data_ptr )
    Remarks Use a regression calc to restore the trend to a data series.


    Function new_tslr_struct
    Include file LINREG_R.H
    Prototype TSLR *new_tslr_struct( int tslr_length )
    Remarks Allocate, initialize and return a virgin Time Series Linear Regression indicator structure.


    Function reset_tslr_struct
    Include file LINREG_R.H
    Prototype void reset_tslr_struct( TSLR *tslr_ptr )
    Remarks Reset a TSLR data structure for a new data series.


    Function update_tslr_struct
    Include file LINREG_R.H
    Prototype void update_tslr_struct( TSLR *tslr_ptr , float data )
    Remarks Update the caller's TSLR with the new data. Once we have collected enough data to calc the regression, tslr_ptr->enough_data will be set to TRUE and the tslr var can be used.


    Function free_tslr_struct
    Include file LINREG_R.H
    Prototype void free_tslr_struct( TSLR *tslr_ptr )
    Remarks Return the TSLR and its sub-structure memory to the system.


    Function new_tslr_ind_struct
    Include file LINREG_R.H
    Prototype TSLR_IND *new_tslr_ind_struct( int data_cnt )
    Remarks Allocate, and return a virgin TSLR indicator display structure for data_cnt items.


    Function free_tslr_ind_struct
    Include file LINREG_R.H
    Prototype void free_tslr_ind_struct( TSLR_IND *tslr_ptr )
    Remarks Return the TSLR indicator display structure and its sub-structure memory to the system.


    Function calc_tslr_ind
    Include file LINREG_R.H
    Prototype void calc_tslr_ind( DATA_REC *data_ptr , int data_cnt , int which_field , TSLR_IND *inds , int tslr_length )
    Remarks Calculate a Time Series least-squares Linear Regression indicator for the requested field of the DATA_REC data series. The indicators will be built in the caller's TSLR_IND indicator display structure inds.


    Table of Contents Function Index

    DFQREG_R.C - Dual FreQuency trigonometric REGression Routines

    ANSI C dual frequency trigonometric regression routines. The math came from Perry Kaufman's book and the errors in the book have been corrected.


    Function calc_2_freq_trig_reg
    Include file DFQREG_R.H
    Prototype FREQ2_REG *calc_2_freq_trig_reg( int data_cnt , float *inp_dt )
    Remarks Calculate a dual frequency trigonometric regression. The input parameter inp_dt is a pointer to a array of floats of data_cnt number of items.


    Function matrix_gaussian_elimination
    Include file DFQREG_R.H
    Prototype void matrix_gaussian_elimination( float matrix[] , float solution[] , int row , int col )
    Remarks Will do a standard Gaussian elimination to solve any N x M array built into a 1-dimension array..


    Function free_freq2_reg_struct
    Include file DFQREG_R.H
    Prototype void free_freq2_reg_struct( FREQ2_REG *freq2_reg_ptr )
    Remarks Return the FREQ2_REG and its sub-structure memory to the system.


    Table of Contents Function Index

    MACD_R.C

    ANSI C Moving Average Convergence / Divergence and Moving Average Convergence / Divergence Histogram routines. All of the MACD routines are front-ended by macros to provide the MACDH routines. And since an MACD is just a dual moving average crossover with one more parameter for a trigger line, the MACD routines have also been front-end by another set of macros for DMAC support (the DMAC new macro will supply a dummy value for the trigger line length). So once the enough_data is field goes TRUE the DMAC value will be in the macd var.

    For an example lets calc a McClellan Oscillator -

    // given 2 float arrays of data : adv[] & decl[]

    mcc_ptr = new_dmac_struct( 19 , 39 , FALSE ) ; for( i = 0 ; 1 < 40 ; i++ )
    update_dmac_struct( mcc_ptr , adv[ i ] - decl[ i ] ) ;

    printf( "McClellan Osc = %4.0f \n" , mcc_ptr->macd ) ;


    Function new_macd_struct
    Include file MACD_R.H
    Prototype MACD *new_macd_struct( int ma_length1 , int ma_length2 , int trigger , int sma_flag )
    Remarks Allocate, initialize and return a virgin moving average convergence / divergence structure. This same structure is also used for calculating MACDHs and DMACs. Set sma_flag to TRUE to calculate simple moving averages and FALSE for exponential averages.


    Function reset_macd_struct
    Include file MACD_R.H
    Prototype void reset_macd_struct( MACD *macd_ptr )
    Remarks Reset a MACD data structure for a new data series.


    Function update_macd_struct
    Include file MACD_R.H
    Prototype void update_macd_struct( MACD *macd_ptr , float data )
    Remarks Update the caller's MACD with the new data. Once we have collected enough data to calc the MACD, macd_ptr->enough_data will be set to TRUE and macd_ptr->macd can be used.


    Function free_macd_struct
    Include file MACD_R.H
    Prototype void free_macd_struct( MACD *macd_ptr )
    Remarks Return the MACD and its sub-structure memory to the system.


    Function calc_emacd
    Include file MACD_R.H
    Prototype void calc_emacd( MACD *macd_ptr , float data )
    Remarks Calculate a new output value for the given exponential MACD indicator structure using the provided data.


    Function calc_smacd
    Include file MACD_R.H
    Prototype void calc_smacd( MACD *macd_ptr , float data )
    Remarks Calculate a new output value for the given simple MACD indicator structure using the provided data.


    Function new_macd_ind_struct
    Include file MACD_R.H
    Prototype MACD_IND *new_macd_ind_struct( int data_cnt )
    Remarks Allocate, and return a virgin moving average convergence / divergence indicator display structure for data_cnt items.


    Function free_macd_ind_struct
    Include file MACD_R.H
    Prototype void free_macd_ind_struct( MACD_IND *macd_ptr )
    Remarks Return the MACD indicator display structure and its sub-structure memory to the system.


    Function calc_macd_ind
    Include file MACD_R.H
    Prototype void calc_macd_ind( DATA_REC *data_ptr , int data_cnt , int which_field , MACD_IND *inds , int ma_length1 , int ma_length2 , int trigger , int sma_flag )
    Remarks Calculate a moving average convergence / divergence indicator of ma_length1 and ma_length2 with a trigger length of trigger for the requested field for the DATA_REC data series. The indicator will be built in the caller's MACD_IND indicator display structure inds. While we are at it we'll also calc the MACD histogram.


    Table of Contents Function Index

    BBAND_R.C

    ANSI C Bollinger Band indicator routines.


    Function new_bband_struct
    Include file BBAND_R.H
    Prototype BBAND *new_bband_struct( int ma_length , float num_of_stddevs )
    Remarks Allocate, initialize and return a virgin Bollinger Band structure.


    Function reset_bband_struct
    Include file BBAND_R.H
    Prototype void reset_bband_struct( BBAND *bband_ptr )
    Remarks Reset a BBAND data structure for a new data series.


    Function update_bband_struct
    Include file BBAND_R.H
    Prototype void update_bband_struct( BBAND *bband_ptr , float data )
    Remarks Update the caller's BBAND with the new data. Once we have collected enough data to calc the BBANDs, bband_ptr->enough_data will be set to TRUE and the Bollinger band fields can be used.


    Function free_bband_struct
    Include file BBAND_R.H
    Prototype void free_bband_struct( BBAND *bband_ptr )
    Remarks Return the BBAND and its sub-structure memory to the system.


    Function new_bband_ind_struct
    Include file BBAND_R.H
    Prototype BBAND_IND *new_bband_ind_struct( int data_cnt )
    Remarks Allocate, and return a virgin Bollinger Band indicator display structure for data_cnt items.


    Function free_bband_ind_struct
    Include file BBAND_R.H
    Prototype void free_bband_ind_struct( BBAND_IND *bband_ptr )
    Remarks Return the BBAND indicator display structure and its sub-structure memory to the system.


    Function calc_bband_ind
    Include file BBAND_R.H
    Prototype void calc_bband_ind( DATA_REC *data_ptr , int data_cnt , int which_field , BBAND_IND *inds , int ma_length , float num_of_stddevs )
    Remarks Calculate a set of Bollinger Band indicators for the requested field for the DATA_REC data series. The indicators will be built in the caller's BBAND_IND indicator display structure inds.


    Table of Contents Function Index

    RSI_R.C

    ANSI C Relative Strength Index routines.


    Function new_rsi_struct
    Include file RSI_R.H
    Prototype RSI *new_rsi_struct( int rsi_length )
    Remarks Allocate, initialize and return a virgin relative strength index structure.


    Function reset_rsi_struct
    Include file RSI_R.H
    Prototype void reset_rsi_struct( RSI *rsi_ptr )
    Remarks Reset a RSI data structure for a new data series.


    Function update_rsi_struct
    Include file RSI_R.H
    Prototype void update_rsi_struct( RSI *rsi_ptr , float new_data )
    Remarks Update the caller's RSI with the new data. Once we have collected enough data to calc the RSI, rsi_ptr->enough_data will be set to TRUE and rsi_ptr->rsi can be used.


    Function free_rsi_struct
    Include file RSI_R.H
    Prototype void free_rsi_struct( RSI *rsi_ptr )
    Remarks Return the RSI memory to the system.


    Function calc_rsi_ind
    Include file RSI_R.H
    Prototype void calc_rsi_ind( DATA_REC *data_ptr , int data_cnt , int which_field , float *inds , int rsi_length )
    Remarks Calculate a RSI indicator of rsi_length for the requested field for the DATA_REC data series. The indicator will be built in the caller's float inds[].


    Table of Contents Function Index

    STOC _R.C

    ANSI C stochastics and Williams' %R routines prototypes and typedefs.


    Function new_stoc_struct
    Include file STOC_R.H
    Prototype STOC *new_stoc_struct( int stoc_length )
    Remarks Allocate, initialize and return a virgin stochastics structure.


    Function reset_stoc_struct
    Include file STOC_R.H
    Prototype void reset_stoc_struct( STOC *stoc_ptr )
    Remarks Reset a STOC data structure for a new data series.


    Function update_stoc_struct
    Include file STOC_R.H
    Prototype void update_stoc_struct( STOC *stoc_ptr , DATA_REC *data_ptr )
    Remarks Update the caller's STOC with the new data. Once we have collected enough data to calc the STOC vars, stoc_ptr->enough_data will be set to TRUE and the %K & %D and the Williams' %R fields can be used.


    Function free_stoc_struct
    Include file STOC_R.H
    Prototype void free_stoc_struct( STOC *stoc_ptr )
    Remarks Return the STOC and its sub-structure memory to the system.


    Function new_stoc_ind_struct
    Include file STOC_R.H
    Prototype STOC_IND *new_stoc_ind_struct( int data_cnt )
    Remarks Allocate, and return a virgin stochastics indicator display structure for data_cnt items.


    Function free_stoc_ind_struct
    Include file STOC_R.H
    Prototype void free_stoc_ind_struct( STOC_IND *stoc_ptr )
    Remarks Return the STOC indicator display structure and its sub-structure memory to the system.


    Function calc_stoc_ind
    Include file STOC_R.H
    Prototype void calc_stoc_ind( DATA_REC *data_ptr , int data_cnt , STOC_IND *inds , int stoc_length )
    Remarks Calculate a set of stochastics indicators for the requested field for the DATA_REC data series. The indicators will be built in the caller's STOC_IND indicator display structure inds.


    Table of Contents Function Index

    WLDPAR_R.C

    ANSI C routines for Welles Wilder's Parabolic Time/Price indicator.


    Function new_par_struct
    Include file WLDPAR_R.H
    Prototype PAR *new_par_struct( float af_step , float af_max )
    Remarks Allocate, initialize and return a virgin Wilder Parabolic Time/Price indicator structure. Now I think most people don't play with the acceleration step factor or the acceleration max so I have front-ended this routine with a macro for a standard initialization without having to pass the parameters.


    Function reset_par_struct
    Include file WLDPAR_R.H
    Prototype void reset_par_struct( PAR *par_ptr )
    Remarks Reset a PAR data structure for a new data series.


    Function update_par_struct
    Include file WLDPAR_R.H
    Prototype void update_par_struct( PAR *par_ptr , DATA_REC *data_ptr )
    Remarks Update the caller's PAR with the new data. The PAR calcs will turn-on with the second data point and par_ptr->enough_data will be set to TRUE and various PAR fields can be used.


    Function new_par_ind_struct
    Include file WLDPAR_R.H
    Prototype PAR_IND *new_par_ind_struct( int data_cnt )
    Remarks Allocate, and return a virgin Wilder Parabolic SAR indicator display structure for data_cnt items.


    Function free_par_ind_struct
    Include file WLDPAR_R.H
    Prototype void free_par_ind_struct( PAR_IND *par_ptr )
    Remarks Return the PAR indicator display structure and its sub-structure memory to the system.


    Function calc_par_ind
    Include file WLDPAR_R.H
    Prototype void calc_par_ind( DATA_REC *data_ptr , int data_cnt , PAR_IND *inds , float af_step , float af_max )
    Remarks Calculate the Wilder Parabolic Stop and Reverse indicators for the user DATA_REC data series. The indicators will be built in the caller's PAR_IND indicator display structure inds. The long and short stops will each be stored in their own float data array for correct plotting.


    Table of Contents Function Index

    RWI_R.C

    ANSI C Mike Poulos' Random Walk Index indicator routines.


    Function new_rwi_struct
    Include file RWI_R.H
    Prototype RWI *new_rwi_struct( int st_length , int lt_length )
    Remarks Allocate, initialize and return a virgin random walk index structure.


    Function reset_rwi_struct
    Include file RWI_R.H
    Prototype void reset_rwi_struct( RWI *rwi_ptr )
    Remarks Reset a RWI data structure for a new data series.


    Function get_circular_index
    Include file RWI_R.H
    Prototype int get_circular_index( int cur_idx , int offset , int idx_max )
    Remarks Support a circular index in both directions.


    Function update_rwi_struct
    Include file RWI_R.H
    Prototype void update_rwi_struct( RWI *rwi_ptr , DATA_REC *data_ptr )
    Remarks Update the caller's RWI with the new data. Once we have collected enough data to calc the RWIs, rwi_ptr->enough_data will be set to TRUE and the 4 rwi vars can be used.


    Function free_rwi_struct
    Include file RWI_R.H
    Prototype void free_rwi_struct( RWI *rwi_ptr )
    Remarks Return the RWI and its sub-structure memory to the system.


    Function new_rwi_ind_struct
    Include file RWI_R.H
    Prototype RWI_IND *new_rwi_ind_struct( int data_cnt )
    Remarks Allocate, and return a virgin random walk index indicator display structure for data_cnt items.


    Function free_rwi_ind_struct
    Include file RWI_R.H
    Prototype void free_rwi_ind_struct( RWI_IND *rwi_ptr )
    Remarks Return the RWI indicator display structure and its sub-structure memory to the system.


    Function calc_rwi_ind
    Include file RWI_R.H
    Prototype void calc_rwi_ind( DATA_REC *data_ptr , int data_cnt , RWI_IND *inds , int st_length , int lt_length )
    Remarks Calculate a set of random walk index indicators for the DATA_REC data series. The indicators will be built in the caller's RWI_IND indicator display structure inds.


    Table of Contents Function Index

    FIBPRJ_R.C - FIBonacci PROjection Routines

    Routines for calculating Fibonacci price retrace and expansion projections.


    Function new_fibprj_struct
    Include file FIBPRJ_R.H
    Prototype FIBPRJ *new_fibprj_struct( void )
    Remarks Allocate and return a Fibonacci price projection data structure.


    Function reset_fibprj_struct
    Include file FIBPRJ_R.H
    Prototype void reset_fibprj_struct( FIBPRJ *fibprj_ptr )
    Remarks Reset a Fibonacci price projection data structure for a new data series. By resetting all fields you can look at fibprj_ptr->pt_c and tell if you did a retrace or an expansion call.


    Function calc_fibonacci_expansions
    Include file FIBPRJ_R.H
    Prototype void calc_fibonacci_expansions( FIBPRJ *fibprj_ptr , float pt_a , float pt_b , float pt_c )
    Remarks Calculate the normal Fibonacci price expansion series for 3 data points and while we're at it let's also call calc_fibonacci_retraces() with data points B & C.


    Function calc_fibonacci_retraces
    Include file FIBPRJ_R.H
    Prototype void calc_fibonacci_retraces( FIBPRJ *fibprj_ptr , float pt_a , float pt_b )
    Remarks Calculate the normal Fibonacci price retrace series for 2 data points.


    Table of Contents Function Index

    CSTM_IND.C

    This module contains the indicator routines for CSTM_RPT. From the abstract view this module meant to process sequentially - globally available DATA_REC data points through the defined report template via the process_records. For each DATA_REC data value each of the defined process records while be called by sequence of their definition (they'll be called in-order). This means for DATA_REC # 1 - process records 1 to N are executed, then DATA_REC # 2 is processed, etc.. Since the process records are processed in order this means that process records can also generate data that can be further processed by subsequent process records on the same DATA_REC pass (exp. DATA_REC # 1 / process record #1 builds a output value that DATA_REC #1 / process record # 2 can then use).

    All of the indicators can be thought of as objects attached to the process records. Each indicator object has two main routines - an allocate routine and a calculate routine (beginning with allocate_ & calc_ respectively). It may also have a initialize routine to reset itself between multiple data series if it needs to (these routines begin with init_). Of course there are other helper routines too. Also some indicator objects are layered on top of other indicator objects (exp. MACDs are built out of SMAs or EMAs). For this reason some indicators also have alloc_ routines that allocate, initialize and return the pointer to a virgin indicator object.

    Also each indicator object internally caches the data that it is provided during the update calls so it is possible to calculate indicators of indicators. Sometimes this could be of dubious value (like calculating a stochastics indicator of a moving average), other times it can be very valuable (like a standard deviation study of any indicator).


    Function init_x1
    Include file CSTM_IND.H
    Prototype void init_x1( void )
    Remarks Initialize the cur_prc_rec's x1 indicator structure.


    Function allocate_x1
    Include file CSTM_IND.H
    Prototype void allocate_x1( void )
    Remarks Allocate a x1 indicator structure and attach it to the cur_prc_rec.


    Function calc_x1
    Include file CSTM_IND.H
    Prototype void calc_x1( void )
    Remarks Calculate the current output value for the x1 indicator attached to the cur_prc_rec.


    Function store_bars_needed
    Include file CSTM_IND.H
    Prototype void store_bars_needed( int bars_needed )
    Remarks Calculate the number of data bars needed before this indicator can start generating output values and used the value to possibly update the master bars_needed data counter.


    Function bars_needed_by_secondary_srcs
    Include file CSTM_IND.H
    Prototype int bars_needed_by_secondary_srcs( int source_idx )
    Remarks Walk back up the data source trail summing all the bars_needed by each secondary data source until we hit a file constant data source.


    Function cnvt_cur_idx_2_last
    Include file CSTM_IND.H
    Prototype int cnvt_cur_idx_2_last( int cur , int max )
    Remarks Handle decrementing a circular queue index.


    Function get_last_output_value_4_cur_prc
    Include file CSTM_IND.H
    Prototype float get_last_output_value_4_cur_prc( void )
    Remarks Fetch the last value outputed by the indicator attached to the cur_prc_rec.


    Function chk_ma_lengths
    Include file CSTM_IND.H
    Prototype void chk_ma_lengths( int *length1 , int *length2 )
    Remarks Verify (and reverse if necessary) that moving average length1 is shorter than moving average length2.


    Function chk_4_ma_tests
    Include file CSTM_IND.H
    Prototype void chk_4_ma_tests( int output_idx , float cur_ma )
    Remarks Check if the current dt_rec is testing a moving average. If it is then update the out_ptr->signal_state to show it.


    Function enough_data_yet
    Include file CSTM_IND.H
    Prototype int enough_data_yet( int minimum_cnt )
    Remarks Return TRUE if we have the minimum number of data bars to calculate this indicator. This routine will also check secondary datas source if used by the cur_prc_rec's indicator object.


    Function init_sma_ptr
    Include file CSTM_IND.H
    Prototype void init_sma_ptr( SMA *sma_ptr )
    Remarks Initialize a given simple moving average indicator structure.


    Function init_sma
    Include file CSTM_IND.H
    Prototype void init_sma( void )
    Remarks Initialize the cur_prc_rec's simple moving average indicator structure.


    Function alloc_sma
    Include file CSTM_IND.H
    Prototype SMA *alloc_sma( int ma_length )
    Remarks Allocate a simple moving average indicator structure and return it to the caller.


    Function allocate_sma
    Include file CSTM_IND.H
    Prototype void allocate_sma( void )
    Remarks Allocate a simple moving average indicator structure and attach it to the cur_prc_rec.


    Function update_sma
    Include file CSTM_IND.H
    Prototype void update_sma( SMA *sma_ptr , float data )
    Remarks Update the given simple moving average indicator structure with the provided data.


    Function calc_sma
    Include file CSTM_IND.H
    Prototype void calc_sma( void )
    Remarks Calculate the current output value for the simple moving average indicator attached to the cur_prc_rec.


    Function init_ema_ptr
    Include file CSTM_IND.H
    Prototype void init_ema_ptr( EMA *ema_ptr )
    Remarks Initialize a given exponential moving average indicator structure.


    Function init_ema
    Include file CSTM_IND.H
    Prototype void init_ema( void )
    Remarks Initialize the cur_prc_rec's exponential moving average indicator structure.


    Function alloc_ema
    Include file CSTM_IND.H
    Prototype EMA *alloc_ema( int ma_length )
    Remarks Allocate a exponential moving average indicator structure and return it to the caller.


    Function allocate_ema
    Include file CSTM_IND.H
    Prototype void allocate_ema( void )
    Remarks Allocate a exponential moving average indicator structure and attach it to the cur_prc_rec.


    Function update_ema
    Include file CSTM_IND.H
    Prototype void update_ema( EMA *ema_ptr , float data )
    Remarks Update the given exponential moving average indicator structure with the provided data.


    Function calc_ema
    Include file CSTM_IND.H
    Prototype void calc_ema( void )
    Remarks Calculate the current output value for the exponential moving average indicator attached to the cur_prc_rec.


    Function init_rsi
    Include file CSTM_IND.H
    Prototype void init_rsi( void )
    Remarks Initialize the cur_prc_rec's Wilder's relative strength index indicator structure.


    Function allocate_rsi
    Include file CSTM_IND.H
    Prototype void allocate_rsi( void )
    Remarks Allocate a relative strength index indicator structure and attach it to the cur_prc_rec.


    Function calc_rsi
    Include file CSTM_IND.H
    Prototype void calc_rsi( void )
    Remarks Calculate the current output value for the relative strength index indicator attached to the cur_prc_rec.


    Function init_shift_data
    Include file CSTM_IND.H
    Prototype void init_shift_data( void )
    Remarks Initialize the cur_prc_rec's shift data forward indicator structure.


    Function allocate_shift_data
    Include file CSTM_IND.H
    Prototype void allocate_shift_data( void )
    Remarks Allocate a shift data indicator structure and attach it to the cur_prc_rec.


    Function calc_shift_data
    Include file CSTM_IND.H
    Prototype void calc_shift_data( void )
    Remarks Calculate the current output value for the shift data indicator attached to the cur_prc_rec.


    Function init_macd
    Include file CSTM_IND.H
    Prototype void init_macd( void )
    Remarks Initialize the cur_prc_rec's MACD (Moving Average Convergence / Divergence ) indicator structure.


    Function alloc_macd
    Include file CSTM_IND.H
    Prototype MACD *alloc_macd( int ma_length1 , int ma_length2 , int trigger )
    Remarks Allocate a new MACD indicator structure and return it to the caller.


    Function allocate_macd
    Include file CSTM_IND.H
    Prototype void allocate_macd( void )
    Remarks Allocate a MACD indicator structure and attach it to the cur_prc_rec.


    Function calc_emacd
    Include file CSTM_IND.H
    Prototype void calc_emacd( MACD *macd_ptr , float data )
    Remarks Calculate a new output value for the given exponential MACD indicator structure using the provided data.


    Function calc_smacd
    Include file CSTM_IND.H
    Prototype void calc_smacd( MACD *macd_ptr , float data )
    Remarks Calculate a new output value for the given simple MACD indicator structure using the provided data.


    Function calc_macd
    Include file CSTM_IND.H
    Prototype void calc_macd( void )
    Remarks Calculate the current output value for the MACD indicator attached to the cur_prc_rec.


    Function allocate_macdh
    Include file CSTM_IND.H
    Prototype void allocate_macdh( void )
    Remarks Allocate a MACDH (Moving Average Convergence / Divergence Histogram) indicator structure and attach it to the cur_prc_rec.


    Function calc_macdh
    Include file CSTM_IND.H
    Prototype void calc_macdh( void )
    Remarks Calculate the current output value for the MACDH indicator attached to the cur_prc_rec.


    Function init_hhigh
    Include file CSTM_IND.H
    Prototype void init_hhigh( void )
    Remarks Initialize the cur_prc_rec's highest high in N bars indicator structure.


    Function allocate_hhigh
    Include file CSTM_IND.H
    Prototype void allocate_hhigh( void )
    Remarks Allocate a highest high in N bars indicator structure and attach it to the cur_prc_rec.


    Function calc_hhigh
    Include file CSTM_IND.H
    Prototype void calc_hhigh( void )
    Remarks Calculate the current output value for the highest high in N bars indicator attached to the cur_prc_rec.


    Function init_llow
    Include file CSTM_IND.H
    Prototype void init_llow( void )
    Remarks Initialize the cur_prc_rec's lowest low in N bars indicator structure.


    Function allocate_llow
    Include file CSTM_IND.H
    Prototype void allocate_llow( void )
    Remarks Allocate a lowest low in N bars indicator structure and attach it to the cur_prc_rec.


    Function calc_llow
    Include file CSTM_IND.H
    Prototype void calc_llow( void )
    Remarks Calculate the current output value for the lowest low in N bars indicator attached to the cur_prc_rec.


    Function allocate_change
    Include file CSTM_IND.H
    Prototype void allocate_change( void )
    Remarks Allocate a net change indicator structure and attach it to the cur_prc_rec.


    Function calc_change
    Include file CSTM_IND.H
    Prototype void calc_change( void )
    Remarks Calculate the current output value for the net change indicator attached to the cur_prc_rec.


    Function allocate_pchange
    Include file CSTM_IND.H
    Prototype void allocate_pchange( void )
    Remarks Allocate a percent change indicator structure and attach it to the cur_prc_rec.


    Function calc_pchange
    Include file CSTM_IND.H
    Prototype void calc_pchange( void )
    Remarks Calculate the current output value for the percent change indicator attached to the cur_prc_rec.


    Function allocate_range
    Include file CSTM_IND.H
    Prototype void allocate_range( void )
    Remarks Allocate a DATA_REC actual range indicator structure and attach it to the cur_prc_rec.


    Function calc_range
    Include file CSTM_IND.H
    Prototype void calc_range( void )
    Remarks Calculate the current output value for the DATA_REC actual range indicator attached to the cur_prc_rec.


    Function allocate_trange
    Include file CSTM_IND.H
    Prototype void allocate_trange( void )
    Remarks Allocate a DATA_REC true range indicator structure and attach it to the cur_prc_rec.


    Function calc_trange
    Include file CSTM_IND.H
    Prototype void calc_trange( void )
    Remarks Calculate the current output value for the DATA_REC true range indicator attached to the cur_prc_rec.


    Function init_stoc
    Include file CSTM_IND.H
    Prototype void init_stoc( void )
    Remarks Initialize the cur_prc_rec's stochastics indicator structure.


    Function alloc_stoc
    Include file CSTM_IND.H
    Prototype STOC *alloc_stoc( int stoc_length , int k_ma_length , int d_ma_length )
    Remarks Allocate a stochastics indicator structure and return it to the caller.


    Function allocate_stoc
    Include file CSTM_IND.H
    Prototype void allocate_stoc( void )
    Remarks Allocate a stochastics indicator structure and attach it to the cur_prc_rec.


    Function calc_stoc
    Include file CSTM_IND.H
    Prototype void calc_stoc( void )
    Remarks Calculate the current output value for the stochastics indicator attached to the cur_prc_rec.


    Function get_highs_and_lows
    Include file CSTM_IND.H
    Prototype void get_highs_and_lows( STOC *stoc_ptr )
    Remarks Find the highest high and lowest low in the data points cached in the stochastic indicator object.


    Function store_stoc_data
    Include file CSTM_IND.H
    Prototype void store_stoc_data( STOC *stoc_ptr )
    Remarks Store the cur_prc_rec data source into the internal cache in the stochastics indicator structure.


    Function allocate_wclose
    Include file CSTM_IND.H
    Prototype void allocate_wclose( void )
    Remarks Allocate a weighted close indicator structure and attach it to the cur_prc_rec.


    Function calc_wclose
    Include file CSTM_IND.H
    Prototype void calc_wclose( void )
    Remarks Calculate the current output value for the weighted close indicator attached to the cur_prc_rec.


    Function allocate_dmac
    Include file CSTM_IND.H
    Prototype void allocate_dmac( void )
    Remarks Allocate a Dual Moving Average Crossover indicator structure and attach it to the cur_prc_rec.


    Function calc_dmac
    Include file CSTM_IND.H
    Prototype void calc_dmac( void )
    Remarks Calculate the current output value for the Dual Moving Average Crossover indicator attached to the cur_prc_rec.


    Function allocate_wr
    Include file CSTM_IND.H
    Prototype void allocate_wr( void )
    Remarks Allocate a Williams' percent R indicator structure and attach it to the cur_prc_rec.


    Function calc_wr
    Include file CSTM_IND.H
    Prototype void calc_wr( void )
    Remarks Calculate the current output value for the Williams' % R indicator attached to the cur_prc_rec.


    Function init_cci
    Include file CSTM_IND.H
    Prototype void init_cci( void )
    Remarks Calculate the current output value for the Commodity Channel Index indicator attached to the cur_prc_rec.


    Function allocate_cci
    Include file CSTM_IND.H
    Prototype void allocate_cci( void )
    Remarks Allocate a Commodity Channel Index indicator structure and attach it to the cur_prc_rec.


    Function calc_cci
    Include file CSTM_IND.H
    Prototype void calc_cci( void )
    Remarks Calculate the current output value for the Commodity Channel Index indicator attached to the cur_prc_rec.


    Function alloc_stddev
    Include file CSTM_IND.H
    Prototype STDDEV *alloc_stddev( int max )
    Remarks Allocate a standard deviation indicator and return it to the caller.


    Function init_stddev
    Include file CSTM_IND.H
    Prototype void init_stddev( STDDEV *stddev_ptr )
    Remarks Initialize the given standard deviation indicator structure.


    Function update_stddev
    Include file CSTM_IND.H
    Prototype void update_stddev( STDDEV *stddev_ptr , float new_data )
    Remarks Update the given standard deviation indicator structure with the provided data.


    Function init_bb
    Include file CSTM_IND.H
    Prototype void init_bb( void )
    Remarks Initialize the cur_prc_rec's Bollinger Bands indicator structure.


    Function allocate_bb
    Include file CSTM_IND.H
    Prototype void allocate_bb( void )
    Remarks Allocate a Bollinger Band indicator structure and attach it to the cur_prc_rec.


    Function calc_bb
    Include file CSTM_IND.H
    Prototype void calc_bb( void )
    Remarks Calculate the current output value for the Bollinger Band indicator attached to the cur_prc_rec.


    Function init_sdev
    Include file CSTM_IND.H
    Prototype void init_sdev( void )
    Remarks Initialize the cur_prc_rec's standard deviation indicator structure.


    Function allocate_stddev
    Include file CSTM_IND.H
    Prototype void allocate_stddev( void )
    Remarks Allocate a standard deviation indicator structure and attach it to the cur_prc_rec.


    Function calc_stddev
    Include file CSTM_IND.H
    Prototype void calc_stddev( void )
    Remarks Calculate the current output value for the standard deviation indicator attached to the cur_prc_rec.


    Function allocate_recnum
    Include file CSTM_IND.H
    Prototype void allocate_recnum( void )
    Remarks Allocate a report record number indicator structure and attach it to the cur_prc_rec.


    Function calc_recnum
    Include file CSTM_IND.H
    Prototype void calc_recnum( void ) // no calc - just dump the real record number
    Remarks Calculate the current output value for the report record number indicator attached to the cur_prc_rec.


    Function init_sum_n
    Include file CSTM_IND.H
    Prototype void init_sum_n( void )
    Remarks Initialize the cur_prc_rec's N bar summation indicator structure.


    Function allocate_sum_n
    Include file CSTM_IND.H
    Prototype void allocate_sum_n( void )
    Remarks Allocate a N bar summation indicator structure and attach it to the cur_prc_rec.


    Function calc_sum_n
    Include file CSTM_IND.H
    Prototype void calc_sum_n( void )
    Remarks Calculate the current output value for the N bar summation indicator attached to the cur_prc_rec.


    Function init_sum
    Include file CSTM_IND.H
    Prototype void init_sum( void )
    Remarks Initialize the cur_prc_rec's total summation indicator structure.


    Function allocate_sum
    Include file CSTM_IND.H
    Prototype void allocate_sum( void )
    Remarks Allocate a total summation indicator structure and attach it to the cur_prc_rec.


    Function calc_sum
    Include file CSTM_IND.H
    Prototype void calc_sum( void )
    Remarks Calculate the current output value for the total summation indicator attached to the cur_prc_rec.


    Function init_roc
    Include file CSTM_IND.H
    Prototype void init_roc( void )
    Remarks Initialize the cur_prc_rec's Rate Of Change indicator structure.


    Function allocate_roc
    Include file CSTM_IND.H
    Prototype void allocate_roc( void )
    Remarks Allocate a Rate Of Change indicator structure and attach it to the cur_prc_rec.


    Function calc_roc
    Include file CSTM_IND.H
    Prototype void calc_roc( void )
    Remarks Calculate the current output value for the Rate Of Change indicator attached to the cur_prc_rec.


    Function init_mom
    Include file CSTM_IND.H
    Prototype void init_mom( void )
    Remarks Initialize the cur_prc_rec's Momentum indicator structure.


    Function allocate_mom
    Include file CSTM_IND.H
    Prototype void allocate_mom( void )
    Remarks Allocate a momentum indicator structure and attach it to the cur_prc_rec.


    Function calc_mom
    Include file CSTM_IND.H
    Prototype void calc_mom( void )
    Remarks Calculate the current output value for the momentum indicator attached to the cur_prc_rec.


    Table of Contents Function Index

    CSTM2IND.C

    This module contains more of the indicator routines for CSTM_RPT.


    Function init_daytype
    Include file CSTM_IND.H
    Prototype void init_daytype( void )
    Remarks Initialize the cur_prc_rec's day type analysis indicator structure.


    Function allocate_daytype
    Include file CSTM_IND.H
    Prototype void allocate_daytype( void )
    Remarks Allocate a day type analysis indicator structure and attach it to the cur_prc_rec.


    Function calc_daytype
    Include file CSTM_IND.H
    Prototype void calc_daytype( void )
    Remarks Calculate the current output value for the day type analysis indicator attached to the cur_prc_rec.


    Function final_day_type_analyze
    Include file CSTM_IND.H
    Prototype void final_day_type_analyze( void )
    Remarks This is a post process routine used for a final day type analysis.


    Function alloc_wuo
    Include file CSTM_IND.H
    Prototype WUO *alloc_wuo( void )
    Remarks Allocate, initialize and return a Williams' Ultimate Oscillator indicator structure. All 3 time periods are per Larry Williams' specs.


    Function calc_ultimate_osc_value
    Include file CSTM_IND.H
    Prototype float calc_ultimate_osc_value( WUO *wuo_ptr )
    Remarks Calculate the current value for the given Williams' Ultimate Oscillator indicator structure.


    Function init_wuo
    Include file CSTM_IND.H
    Prototype void init_wuo( void )
    Remarks Initialize the cur_prc_rec's Williams' Ultimate Oscillator indicator structure.


    Function allocate_wuo
    Include file CSTM_IND.H
    Prototype void allocate_wuo( void )
    Remarks Allocate a Williams' Ultimate Oscillator indicator structure and attach it to the cur_prc_rec.


    Function calc_wuo
    Include file CSTM_IND.H
    Prototype void calc_wuo( void )
    Remarks Calculate the current output value for the Williams' Ultimate Oscillator indicator attached to the cur_prc_rec.


    Function init_chaikin
    Include file CSTM_IND.H
    Prototype void init_chaikin( void )
    Remarks Initialize the cur_prc_rec's Chaikin's volume indicator structure.


    Function allocate_chaikin
    Include file CSTM_IND.H
    Prototype void allocate_chaikin( void )
    Remarks Allocate a Chaikin's volume indicator structure and attach it to the cur_prc_rec.


    Function calc_chaikin
    Include file CSTM_IND.H
    Prototype void calc_chaikin( void )
    Remarks Calculate the current output value for the Chaikin's volume indicator attached to the cur_prc_rec.


    Function allocate_pivot_pts
    Include file CSTM_IND.H
    Prototype void allocate_pivot_pts( void )
    Remarks Allocate a pivot point indicator structure and attach it to the cur_prc_rec.


    Function calc_pivot_pts
    Include file CSTM_IND.H
    Prototype void calc_pivot_pts( void )
    Remarks Calculate the current output value for the pivot point indicator attached to the cur_prc_rec.


    Function update_wld_ma_ptr
    Include file CSTM_IND.H
    Prototype void update_wld_ma_ptr( WLD_MA *wld_ma_ptr , float data )
    Remarks Update the given Wilder's Moving Average indicator structure with the new data.


    Function init_wld_ma_ptr
    Include file CSTM_IND.H
    Prototype void init_wld_ma_ptr( WLD_MA *wld_ma_ptr )
    Remarks Initialize the cur_prc_rec's Wilder's Moving Average indicator structure.


    Function alloc_wld_ma
    Include file CSTM_IND.H
    Prototype WLD_MA *alloc_wld_ma( int ma_length , int sum_or_avg )
    Remarks Allocate a Wilder's Moving Average indicator structure and attach it to the cur_prc_rec.


    Function init_dmi
    Include file CSTM_IND.H
    Prototype void init_dmi( void )
    Remarks Initialize the cur_prc_rec's Wilder's Directional Movement indicator structure.


    Function allocate_dmi
    Include file CSTM_IND.H
    Prototype void allocate_dmi( void )
    Remarks Allocate a Wilder's Directional Movement indicator structure and attach it to the cur_prc_rec.


    Function calc_dmi
    Include file CSTM_IND.H
    Prototype void calc_dmi( void )
    Remarks Calculate the current output value for the Wilder's Directional Movement indicator attached to the cur_prc_rec.


    Function init_par
    Include file CSTM_IND.H
    Prototype void init_par( void )
    Remarks Initialize the cur_prc_rec's Wilder's parabolic stop and reverse indicator structure.


    Function allocate_par
    Include file CSTM_IND.H
    Prototype void allocate_par( void )
    Remarks Allocate a Wilder's parabolic stop and reverse indicator structure and attach it to the cur_prc_rec.


    Function calc_par
    Include file CSTM_IND.H
    Prototype void calc_par( void )
    Remarks Calculate the current output value for the Wilder's parabolic stop and reverse indicator attached to the cur_prc_rec.


    Function init_obv
    Include file CSTM_IND.H
    Prototype void init_obv( void )
    Remarks Initialize the cur_prc_rec's Granville's On Balance Volume indicator structure.


    Function allocate_obv
    Include file CSTM_IND.H
    Prototype void allocate_obv( void )
    Remarks Allocate a Granville's On Balance Volume indicator structure and attach it to the cur_prc_rec.


    Function calc_obv
    Include file CSTM_IND.H
    Prototype void calc_obv( void )
    Remarks Calculate the current output value for the Granville's On Balance Volume indicator attached to the cur_prc_rec.


    Function init_nvi
    Include file CSTM_IND.H
    Prototype void init_nvi( void )
    Remarks Initialize the cur_prc_rec's Negative Volume Index indicator structure.


    Function allocate_nvi
    Include file CSTM_IND.H
    Prototype void allocate_nvi( void )
    Remarks Allocate a Negative Volume Index indicator structure and attach it to the cur_prc_rec.


    Function calc_nvi
    Include file CSTM_IND.H
    Prototype void calc_nvi( void )
    Remarks Calculate the current output value for the Negative Volume Index indicator attached to the cur_prc_rec.


    Function init_pvi
    Include file CSTM_IND.H
    Prototype void init_pvi( void )
    Remarks Initialize the cur_prc_rec's Positive Volume Index indicator structure.


    Function allocate_pvi
    Include file CSTM_IND.H
    Prototype void allocate_pvi( void )
    Remarks Allocate a Positive Volume Index indicator structure and attach it to the cur_prc_rec.


    Function calc_pvi
    Include file CSTM_IND.H
    Prototype void calc_pvi( void )
    Remarks Calculate the current output value for the Positive Volume Index indicator attached to the cur_prc_rec.


    Function calc_linreg
    Include file CSTM_IND.H
    Prototype void calc_linreg( LINREG *linreg , int data_max , float *data )
    Remarks Calculate and update the given linear regression indicator structure for the data series provided.


    Function init_tslr
    Include file CSTM_IND.H
    Prototype void init_tslr( void )
    Remarks Initialize the cur_prc_rec's Time Series Linear Regression indicator structure.


    Function allocate_tslr
    Include file CSTM_IND.H
    Prototype void allocate_tslr( void )
    Remarks Allocate a Time Series Linear Regression indicator structure and attach it to the cur_prc_rec.


    Function calc_tslr
    Include file CSTM_IND.H
    Prototype void calc_tslr( void )
    Remarks Calculate the current output value for the Time Series Linear Regression indicator attached to the cur_prc_rec.


    Function init_ad
    Include file CSTM_IND.H
    Prototype void init_ad( void )
    Remarks Initialize the cur_prc_rec's Accumulation / Distribution indicator structure.


    Function allocate_ad
    Include file CSTM_IND.H
    Prototype void allocate_ad( void )
    Remarks Allocate a Accumulation / Distribution indicator structure and attach it to the cur_prc_rec.


    Function calc_ad
    Include file CSTM_IND.H
    Prototype void calc_ad( void )
    Remarks Calculate the current output value for the Accumulation / Distribution indicator attached to the cur_prc_rec.


    Function set_data_labels_complex
    Include file CSTM_IND.H
    Prototype void set_data_labels_complex( MATHOP *mathop_ptr )
    Remarks This is a specialized subset version of set_data_source_n_labels() to build output labels for math operation processes.


    Function set_data_source_complex
    Include file CSTM_IND.H
    Prototype void set_data_source_complex( int *src_type , int *src_idx , float *src_constant )
    Remarks This is a specialized subset version of set_data_source_n_labels() to set the data sources for math operation processes.


    Function init_mathop
    Include file CSTM_IND.H
    Prototype void init_mathop( void )
    Remarks Initialize the cur_prc_rec's math operation indicator structure.


    Function allocate_mathop
    Include file CSTM_IND.H
    Prototype void allocate_mathop( void )
    Remarks Allocate a math operation indicator structure and attach it to the cur_prc_rec.


    Function calc_mathop
    Include file CSTM_IND.H
    Prototype void calc_mathop( void )
    Remarks Calculate the current output value for the math operation indicator attached to the cur_prc_rec.


    Function allocate_srat
    Include file CSTM_IND.H
    Prototype void allocate_srat( void )
    Remarks Allocate a signed ratio indicator structure and attach it to the cur_prc_rec.


    Function calc_srat
    Include file CSTM_IND.H
    Prototype void calc_srat( void )
    Remarks Calculate the current output value for the signed ratio indicator attached to the cur_prc_rec.


    Function init_trix
    Include file CSTM_IND.H
    Prototype void init_trix( void )
    Remarks Initialize the cur_prc_rec's TRIX indicator structure.


    Function allocate_trix
    Include file CSTM_IND.H
    Prototype void allocate_trix( void )
    Remarks Allocate a TRIX indicator structure and attach it to the cur_prc_rec.


    Function calc_trix
    Include file CSTM_IND.H
    Prototype void calc_trix( void )
    Remarks Calculate the current output value for the TRIX indicator attached to the cur_prc_rec.


    Function init_trix
    Include file CSTM_IND.H
    Prototype void init_trix( void )
    Remarks Initialize the cur_prc_rec's non-log TRIX indicator structure.


    Function allocate_trix
    Include file CSTM_IND.H
    Prototype void allocate_trix( void )
    Remarks Allocate a non-log TRIX indicator structure and attach it to the cur_prc_rec.


    Function calc_trix
    Include file CSTM_IND.H
    Prototype void calc_trix( void )
    Remarks Calculate the current output value for the non-log TRIX indicator attached to the cur_prc_rec.


    Function allocate_thigh
    Include file CSTM_IND.H
    Prototype void allocate_thigh( void )
    Remarks Allocate a True High indicator structure and attach it to the cur_prc_rec.


    Function calc_thigh
    Include file CSTM_IND.H
    Prototype void calc_thigh( void )
    Remarks Calculate the current output value for the True High indicator attached to the cur_prc_rec.


    Function allocate_tlow
    Include file CSTM_IND.H
    Prototype void allocate_tlow( void )
    Remarks Allocate a True Low indicator structure and attach it to the cur_prc_rec.


    Function calc_tlow
    Include file CSTM_IND.H
    Prototype void calc_tlow( void )
    Remarks Calculate the current output value for the True Low indicator attached to the cur_prc_rec.


    Function allocate_max
    Include file CSTM_IND.H
    Prototype void allocate_max( void )
    Remarks Allocate a Max indicator structure and attach it to the cur_prc_rec.


    Function allocate_min
    Include file CSTM_IND.H
    Prototype void allocate_min( void )
    Remarks Allocate a Min indicator structure and attach it to the cur_prc_rec.


    Function init_rwi
    Include file CSTM_IND.H
    Prototype void init_rwi( void )
    Remarks Initialize the cur_prc_rec's random walk index indicator structure.


    Function allocate_rwi
    Include file CSTM_IND.H
    Prototype void allocate_rwi( void )
    Remarks Allocate a random walk index indicator structure and attach it to the cur_prc_rec.


    Function calc_rwi
    Include file CSTM_IND.H
    Prototype void calc_rwi( void )
    Remarks Calculate the current output value for the random walk index indicator attached to the cur_prc_rec.


    Function init_ama
    Include file CSTM_IND.H
    Prototype void init_ama( void )
    Remarks Initialize the cur_prc_rec's adaptive moving average indicator structure.


    Function allocate_ama
    Include file CSTM_IND.H
    Prototype void allocate_ama( void )
    Remarks Allocate a adaptive moving average indicator structure and attach it to the cur_prc_rec.


    Function calc_ama
    Include file CSTM_IND.H
    Prototype void calc_ama( void )
    Remarks Calculate the current output value for the adaptive moving average indicator attached to the cur_prc_rec.


    Function init_wma
    Include file CSTM_IND.H
    Prototype void init_wma( void )
    Remarks Initialize the cur_prc_rec's weighted moving average indicator structure.


    Function allocate_wma
    Include file CSTM_IND.H
    Prototype void allocate_wma( void )
    Remarks Allocate a weighted moving average indicator structure and attach it to the cur_prc_rec.


    Function calc_wma
    Include file CSTM_IND.H
    Prototype void calc_wma( void )
    Remarks Calculate the current output value for the weighted moving average indicator attached to the cur_prc_rec.


    Table of Contents Function Index

    DTFL_ACC.C - DaTa FiLe ACCess routines

    Standardized data file access routines to support Computrac/Metastock, CSI and ASCII data files. For use by the commercial TDF product line. At a abstract level this module is driven by ticker_strs and returns standard records of type DATA_REC (date,high,low,close,vol,open,open_int). It expects that the GLOBAL vars data_path & database_type have already been setup. Random and sequential access is supported for all database types.

    standard call flow -
    1. - int lookup_data_file_num()
    2. - FILE *open_date_file()
    3. - int get_data_record_n() and then multiple
    int get_next_data_record() Or this alternate method
    1. - int lookup_data_file_num()
    2. - FILE *open_date_file()
    3. - int load_one_intraday_day()

    There is also a lazy-mans do everything routine in MEMCPTDT.C that is layered on this module -
    1. - DATA_REC *load_last_n_data_records()


    Function lookup_data_file_num
    Include file DTFL_ACC.H
    Prototype int lookup_data_file_num( char *requested_ticker )
    Remarks Main first entry for this module. We need to look up the user's ticker str in the master file, fetch the data file number and build the data file names. This is the master dispatch routine. After lookup the GLOBAL vars fnd_ticker & fnd_ticker_label will be filled.


    Function lookup_cpt_data_file_num
    Include file DTFL_ACC.H
    Prototype int lookup_cpt_data_file_num( char *ticker )
    Remarks The Computrac/Metastock master file lookup routine.


    Function make_data_file_name
    Include file DTFL_ACC.H
    Prototype void make_data_file_name( int data_file_num )
    Remarks data_path/F%d.dat


    Function make_dop_file_name
    Include file DTFL_ACC.H
    Prototype void make_dop_file_name( int data_file_num )
    Remarks data_path/F%d.dop


    Function eat_EQUIS_flag_char
    Include file DTFL_ACC.H
    Prototype void eat_EQUIS_flag_char( char *str , int cnt )
    Remarks EQUIS adds a flag character of a "*" to the end of the master.ticker so we need to eat it before we compare to the user's ticker_str.


    Function trim_trailing_white_space_2_cnt
    Include file DTFL_ACC.H
    Prototype void trim_trailing_white_space_2_cnt( char *str , int cnt )
    Remarks Trim a string to only useable stuff before we compare to it.


    Function correct_CSI_ticker_error
    Include file DTFL_ACC.H
    Prototype void correct_CSI_ticker_error( char *str , int cnt )
    Remarks CSI does not handle creating ticker fields in a Metastock master file correctly. They don't bother to init the unused space to spaces but they just leave it random dirty values. They just insert a single trailing space - by them using the space as a delimiter - it means you can't have embedded spaces in your ticker string.


    Function lookup_csi_data_file_num
    Include file DTFL_ACC.H
    Prototype int lookup_csi_data_file_num( char *ticker )
    Remarks The CSI master file lookup routine.


    Function chk_this_csi_master_rec
    Include file DTFL_ACC.H
    Prototype int chk_this_csi_master_rec( char *ticker )
    Remarks Compare the current csi_master to the user ticker, return TRUE if got_it


    Function init_data_file_temps
    Include file DTFL_ACC.H
    Prototype void init_data_file_temps( void )
    Remarks Initialize module & subsystem variables before the data file open.


    Function open_data_file
    Include file DTFL_ACC.H
    Prototype FILE *open_data_file( void )
    Remarks Main second entry point for this module. Open the data file pointed to by the data_file_name. After the open GLOBAL vars - num_of_data_recs, first_date_in_file, last_date_in_file, & output_places will have been set. Also for ASCII data we need to load the whole file now into far memory so we can support run-time user requests for specific records.


    Function set_cpt_output_places
    Include file DTFL_ACC.H
    Prototype int set_cpt_output_places( void )
    Remarks Computrac/Metastock doesn't have a scaler conversion factor like CSI so we need to calculate one.


    Function get_data_record_n
    Include file DTFL_ACC.H
    Prototype void get_data_record_n( FILE *data_file , UINT rec_num , DATA_REC *data_ptr )
    Remarks Main entry point # 3. Now that we have looked up the ticker and opened the file, let's get a specific record for the user.


    Function get_next_data_record
    Include file DTFL_ACC.H
    Prototype void get_next_data_record( FILE *data_file , DATA_REC *data_ptr )
    Remarks Main entry point # 4. Once we have first called get_data_record_n we then can call here repeatedly to fetch the next records in the file.


    Function cnvt_cpt_data_rec
    Include file DTFL_ACC.H
    Prototype void cnvt_cpt_data_rec( DATA_REC *data_ptr )
    Remarks Convert the current Computrac data record into the user's DATA_REC.


    Function load_one_intraday_day
    Include file DTFL_ACC.H
    Prototype void load_one_intraday_day( FILE *data_file , DATA_REC *data_ptr , int day_num , int bars_per_day )
    Remarks Alternate entry point to # 3 & 4. Given the day_num in the file and the intraday bars_per_day, this routine will calc the offset into the file and load one day's worth of intraday data.


    Function read_dop_file
    Include file DTFL_ACC.H
    Prototype void read_dop_file( char *dop_line )
    Remarks Called by rd_ascii_data_file to process each line in a Computrac DOP file. This routine will set the field index pointers for the data record convert.


    Function store_csi_1st_rec_data
    Include file DTFL_ACC.H
    Prototype void store_csi_1st_rec_data( char *buff )
    Remarks Convert and store the CSI vars - csi_file_end_rec_ptr, csi_max_data_ptr, csi_highest_high & csi_lowest_low as well as the normal first_date_in_file & last_date_in_file.


    Function cnvt_csi_data_rec
    Include file DTFL_ACC.H
    Prototype void cnvt_csi_data_rec( DATA_REC *data_ptr )
    Remarks Convert a CSI data record into the user's DATA_REC.


    Function csi_points_2_dollars
    Include file DTFL_ACC.H
    Prototype float csi_points_2_dollars( long ltemp )
    Remarks Convert and scale a CSI data value into a normal float.


    Function csi_2byte_convert
    Include file DTFL_ACC.H
    Prototype void csi_2byte_convert( int var , float *float_ptr )
    Remarks Convert and scale a CSI 2byte data value into a normal float.


    Function csi_3byte_convert
    Include file DTFL_ACC.H
    Prototype void csi_3byte_convert( int var , int var2 , float *float_ptr )
    Remarks Convert and scale a CSI 3byte data value into a normal float.


    Function strncpy_n_uppercase_it
    Include file DTFL_ACC.H
    Prototype void strncpy_n_uppercase_it( char *dest , char *src , int cnt )
    Remarks Do a normal strncpy into a local var & do a uppercase at the same time.


    Function cnvt_null_bytes_2_spaces
    Include file DTFL_ACC.H
    Prototype void cnvt_null_bytes_2_spaces( char *dest , int cnt )
    Remarks Change embedded null bytes (which are C str terminaters) into spaces which are harmless.


    Function print_data_struct
    Include file DTFL_ACC.H
    Prototype void print_data_struct( DATA_REC *data_ptr )
    Remarks If we get an error during the conversion of the raw data record (CSI/CPT) into the DATA_REC we come here to dump a debug look.


    Function print_csi_1st_recs
    Include file DTFL_ACC.H
    Prototype void print_csi_1st_recs( void )
    Remarks If we get an error during the conversion of the 1st CSI raw data record we come here to dump a debug look.


    Function find_last_record
    Include file DTFL_ACC.H
    Prototype void find_last_record( FILE *file_ptr )
    Remarks Read a CSI data file backwards till the 1st non-zero close.


    Function clear_data_rec
    Include file DTFL_ACC.H
    Prototype void clear_data_rec( DATA_REC *data_ptr )
    Remarks Clear all the fields in the user's DATA_REC before the record fetch.


    Function print_cpt_master_rec
    Include file DTFL_ACC.H
    Prototype void print_cpt_master_rec( CPT_MASTER_REC *master )
    Remarks If log_master_2_output_device is set lookup_cpt_data_file_num will call here to dump the current cpt_master.


    Function cnvt_DATA_REC_2_MINI
    Include file DTFL_ACC.H
    Prototype MINI_DATA_REC *cnvt_DATA_REC_2_MINI( DATA_REC *src , MINI_DATA_REC *dest , int recs )
    Remarks Convert a normal DATA_REC (7 fields) into a MINI_DATA_REC (4 fields) to save memory. Will do a automatic realloc if src == dest.


    Function lookup_ascii_data_file
    Include file DTFL_ACC.H
    Prototype int lookup_ascii_data_file( char *ticker )
    Remarks ASCII data files are expected to be named ticker.ext where ext is one of [ TXT , ASC , PRN , LOG ], so if we find one we will set the data_file_name for the future open_data_file() call.


    Function chk_4_ascii_data_file
    Include file DTFL_ACC.H
    Prototype int chk_4_ascii_data_file( char *ticker , char *ext_str )
    Remarks Check the disk for a specific ticker and extention str combination. If we get a hit, we'll also save the fnd_ticker & fnd_ticker_label vars. Return TRUE if found else FALSE.


    Function farrealloc
    Include file DTFL_ACC.H
    Prototype static void far *farrealloc( void far *old_block , ULONG bytes_needed )
    Remarks since Microsoft doesn't have a farrealloc() we need to do it ourself nope they now got one as of V6.0 except I don't like V6.0 so take your choice.


    Function farrealloc
    Include file DTFL_ACC.H
    Prototype static void far *farrealloc( void far *old_block , size_t bytes_needed )
    Remarks


    Function fetch_far_data_rec
    Include file DTFL_ACC.H
    Prototype void fetch_far_data_rec( DATA_REC far *src_ptr , DATA_REC *dest_ptr )
    Remarks Fetch a ASCII data record from far memory into the user's DATA_REC.


    Function open_n_load_ascii_data_file
    Include file DTFL_ACC.H
    Prototype FILE *open_n_load_ascii_data_file( void )
    Remarks Called by open_data_file, but will do much more. We need to load the whole file now into memory so the user at run-time can request random records.


    Function process_1_ascii_line
    Include file DTFL_ACC.H
    Prototype void process_1_ascii_line( char *line )
    Remarks Called by ld_ascii_data_file to process individual ASCII data records.


    Function cnvt_commas_2_white_space
    Include file DTFL_ACC.H
    Prototype void cnvt_commas_2_white_space( char *str )
    Remarks Convert all commas in str to harmless spaces.


    Function fetch_data_field
    Include file DTFL_ACC.H
    Prototype float fetch_data_field( DATA_REC *data_ptr , int which )
    Remarks Return the requested field from the DATA_REC (do the field switch() in one place so everybody can reuse). The field reference constants to use in the which parameter are - DF_DATE , DF_HIGH , DF_LOW , DF_CLOSE , DF_VOL , DF_OPEN & DF_OINT and are defined in DTFL_ACC.H.


    Function store_data_field
    Include file DTFL_ACC.H
    Prototype void store_data_field( float new_data , DATA_REC *data_ptr , int which )
    Remarks Store a new data value into a requested field in a DATA_REC (do the field switch() in one place so everybody can reuse).


    Function ld_ind_from_DATA_REC_series
    Include file DTFL_ACC.H
    Prototype void ld_ind_from_DATA_REC_series( float *inds , DATA_REC *data_ptr , int rec_cnt , int which )
    Remarks Load a daily data value or indicator value into a indicator data series from a compacted DATA_REC data series. An example might be storing


    Function store_ind_in_DATA_REC_series
    Include file DTFL_ACC.H
    Prototype void store_ind_in_DATA_REC_series( float *inds , DATA_REC *data_ptr , int rec_cnt , int which )
    Remarks Store a daily data value or indicator value into specific field of a DATA_REC data series to form a compacted DATA_REC data series for later output to disk.


    Table of Contents Function Index

    STDBPATH.C - SeT DataBase PATH

    The standard database path routines. These 4 routines have been broken out from DTFL_ACC.C (which is where they belong) so programs like FIB_CALC could use them and not suck in all the data access routines they don't need. The define_database() call is used by programs that don't use program configuration files. Program that do use prc_cnfg.c will get the validate_data_type() and validate_data_path_str() called for them from the cnfg_table and just need to call set_database_vars().


    Function define_database
    Include file STDBPATH.H
    Prototype void define_database( char *database_type , char *database_path )
    Remarks Define and validate a database.


    Function validate_data_type
    Include file STDBPATH.H
    Prototype void validate_data_type( char *str )
    Remarks Validate the user requested data_type with the module local char *data_types[]. Set GLOBAL var database_type with either the valid type or DATA_UNKNOWN.


    Function validate_data_path_str
    Include file STDBPATH.H
    Prototype void validate_data_path_str( char *str )
    Remarks This routine just validates that the user str is a valid terminated file path str. The actual validation of the data directory can't happen until we also know the database_type so we'll have to wait till the next routine for that. The GLOBAL var data_path will be set with its own copy of the final str.


    Function set_database_vars
    Include file STDBPATH.H
    Prototype void set_database_vars( void )
    Remarks Set the GLOBAL vars master_rec_size & data_rec_size. Also now validate that the data_path directory does have a master file.


    Table of Contents Function Index

    WRT_DT_R.C - WRiTe DaTa Routines

    ANSI C routines to support creation, writing & updating of CompuTrac & MetaStock datafiles. Warning though - they do not update the label field in the master record. Also creation & writing of ASCII files is supported.

    There are 4 main entry points to this module.

    output_cpt_dt_file() is used to write a data series to disk in a
    binary Computrac/Metastock format. The resulting data file will
    contain only the given data.

    output_ascii_dt_file() is used to write a data series to disk in a
    ASCII format. The resulting data file will contain only the given data.

    append_cpt_dt_file() is used to append a data series to a disk file.
    The data file will contain its original data plus the new data.

    update_cpt_data_record() is used to update an existing data record
    on disk.
    update_cpt_data_record() standard call flow -
    1. lookup_data_file_num() // lookup your ticker
    2. open_date_file_4_update()
    3. get_data_record_n() // fetch the target record
    4. do your updating on the DATA_REC
    5. update_cpt_data_record() // and put it back


    Function output_cpt_dt_file
    Include file WRT_DT_R.H
    Prototype void output_cpt_dt_file( char *dtbase_path , char *ticker , DATA_REC *data_ptr , int rec_cnt , int field_cnt )
    Remarks This is the only routine you need to call to get a data series dumped to disk as a Computrac / Metastock data file. This one call will do it all (assuming you do have a master file in the dtbase_path directory).


    Function append_cpt_dt_file
    Include file WRT_DT_R.H
    Prototype void append_cpt_dt_file( char *ticker , DATA_REC *data , int rec_cnt , int field_cnt )
    Remarks Use this routine to append 1 to N new records to a Computrac / Metastock data file contained in the current database directory data_path.


    Function update_cpt_data_record
    Include file WRT_DT_R.H
    Prototype void update_cpt_data_record( FILE *data_file , DATA_REC *new_data , UINT rec_num )
    Remarks Update a target Computrac / Metastock data rec on disk with the user's DATA_REC. This routine does not update the record count field in the data file header nor the date fields in the master file so it must only be used to update existing records.


    Function empty_cpt_data_file
    Include file WRT_DT_R.H
    Prototype void empty_cpt_data_file( int data_file_num )
    Remarks Delete an existing data file and build a new data file with just a file header in it.


    Function create_cpt_data_file
    Include file WRT_DT_R.H
    Prototype void create_cpt_data_file( int data_file_num )
    Remarks Create a new data file and update the master file to reflect it.


    Function create_cpt_dop_file
    Include file WRT_DT_R.H
    Prototype void create_cpt_dop_file( int data_file_num )
    Remarks Create a 4, 5, 6 or 7 field (as created by Metastock RT) dop file.


    Function update_cpt_master_file
    Include file WRT_DT_R.H
    Prototype void update_cpt_master_file( CPT_MASTER_REC *mstrec_ptr , int rec_num )
    Remarks Update the disk master file with this individual master record.


    Function update_cpt_master_file_cnts
    Include file WRT_DT_R.H
    Prototype void update_cpt_master_file_cnts( void )
    Remarks Update the master file data file number counts in the file header.


    Function update_cpt_dt_file_reccnt
    Include file WRT_DT_R.H
    Prototype void update_cpt_dt_file_reccnt( void )
    Remarks Update the data file's record count in the file header.


    Function get_cur_cpt_master_rec
    Include file WRT_DT_R.H
    Prototype CPT_MASTER_REC *get_cur_cpt_master_rec( void )
    Remarks Get a copy of the master file record that cpt_master_found_idx is pointing at.


    Function get_new_cpt_master_rec
    Include file WRT_DT_R.H
    Prototype CPT_MASTER_REC *get_new_cpt_master_rec( char *ticker , int file_num )
    Remarks Build a new master file record for this ticker.


    Function open_data_file_4_update
    Include file WRT_DT_R.H
    Prototype FILE *open_data_file_4_update( void )
    Remarks Open the data file in update mode ( "r+b" ).


    Function cnvt_DATA_REC_2_cpt_dt_format
    Include file WRT_DT_R.H
    Prototype void cnvt_DATA_REC_2_cpt_dt_format( DATA_REC *dt_ptr , long cpt_dt_recs[] )
    Remarks Convert the DATA_REC record into a Computrac record ready to store to disk.


    Function output_ascii_dt_file
    Include file WRT_DT_R.H
    Prototype void output_ascii_dt_file( char *out_file_name , DATA_REC *data_ptr , int rec_cnt , int out_7_field )
    Remarks Output a DATA_REC series to a ASCII file for passing to another program.


    Function calc_output_places
    Include file WRT_DT_R.H
    Prototype int calc_output_places( DATA_REC *data_ptr )
    Remarks Calculate a output_places value for a given DATA_REC data series. The calculation is based on the first close in the series.


    Table of Contents Function Index

    MEMCPTDT.C - MEMory ComPuTrac DaTa fetch routines

    These are a few routines layered on top of the standard datafile access routines to support memory caching of the master file info. The module is slightly mis-named, only Metastock memory caching & lookup is supported (to support Computrac you just need to check a different field).

    The other major functions in this module - find_date_record_by_date() and load_last_n_data_records() do support all database types.


    Function find_data_record_by_date
    Include file MEMCPTDT.H
    Prototype int find_data_record_by_date( char *date_str , char *ticker )
    Remarks Given a ticker_str and a target_date, this routine will lookup and open the data file and do a binary search for the target date. The routine only looks for exact hits, use find_data_record_by_date_fsearch to forward search through a file for a target date. Returns are FALSE (0) - ticker or record not found, -1 - bounds error ( target_date < first_date_in_file or target_date > last_date_in_file ) else the found record number. The input date_str is in MM/DD/YY format.


    Function find_data_rec_by_date_fsearch
    Include file MEMCPTDT.H
    Prototype int find_data_rec_by_date_fsearch( char *date_str , char *ticker )
    Remarks This routine will front-end find_data_record_by_date() to support forward searching a data file for a target date. Retrys are controlled by FIND_REC_BY_DATE_RETRY_MAX and internal to the routine, dates are handled in julian (so 01/01/90 follows 12/31/89). The input date_str is in MM/DD/YY format.


    Function compare_dates
    Include file MEMCPTDT.H
    Prototype static int compare_dates( float date1 , float date2 )
    Remarks A simple compare function that returns values like strcmp, 0 = match, -1 = date1 < date2 and 1 = date1 > date2.


    Function load_last_n_data_records
    Include file MEMCPTDT.H
    Prototype DATA_REC *load_last_n_data_records( char *ticker , int last_cnt )
    Remarks Given a ticker_str this routine will lookup and open the file, calloc a chunk of memory for the data records, load the last_cnt number of records from the file and return the fetched data in a DATA_REC array.


    Function copy_ticker_str
    Include file MEMCPTDT.H
    Prototype void copy_ticker_str( char far *dest , char far *src )
    Remarks Copy till the 1st WHITE space char on 2 far strs.


    Function ld_cpt_master_file_into_memory
    Include file MEMCPTDT.H
    Prototype void ld_cpt_master_file_into_memory( void )
    Remarks Load a Metastock master file into memory for fast ticker lookup. This routine currently does not support Computrac (all you need to do to add support is change the lookup field).


    Function free_cpt_master_file_rec
    Include file MEMCPTDT.H
    Prototype void free_cpt_master_file_rec( void )
    Remarks Return the old memory master file structure to far heap memory.


    Function mem_lookup_data_file_num
    Include file MEMCPTDT.H
    Prototype int mem_lookup_data_file_num( char *requested_ticker )
    Remarks This routine will automatically support memory caching of Metastock master files for fast ticker lookup. If called with the GLOBAL var database_type != DATA_METASTOCK or the GLOBAL var no_mem_lookup == TRUE then the lookup will be performed by the standard lookup_data_file_num().


    Function find_ticker_with_wildcard_supp
    Include file MEMCPTDT.H
    Prototype int find_ticker_with_wildcard_supp( int init_flag , char *ticker_str )
    Remarks Search the master file memory structure for a user ticker_str by calling match_str_with_wildcard_support() whichs supports embedded "?"s as any one single character (just like MSDOS does). Call this routine with init_flag == TRUE to get the first match, then with init_flag == FALSE to get additional matches. Will return FALSE if no matches else TRUE if found and GLOBAL var cpt_master_found_idx will be set to the correct index in the master memory record of the found record.


    Function update_db_module_vars
    Include file MEMCPTDT.H
    Prototype static void update_db_module_vars( int mem_mst_idx )
    Remarks Update the data access module vars with the info from the found memory cached master record.


    Function strcmp_fr_2_fr
    Include file MEMCPTDT.H
    Prototype static int strcmp_fr_2_fr( char far *a_str , char far *b_str )
    Remarks This is a normal strcmp hacked to support far data ptrs in the small memory model.


    Function strcpy_fr_2_fr
    Include file MEMCPTDT.H
    Prototype static char far * strcpy_fr_2_fr( char far *dest , char far *src )
    Remarks ditto


    Function strncpy_fr_2_fr
    Include file MEMCPTDT.H
    Prototype static char far * strncpy_fr_2_fr( char far *dest , char far *src , int maxlen )
    Remarks ditto


    Table of Contents Function Index

    OUTDEV_R.C

    The standard output_device support routines. This module allocates the flags and the FILE *output_device. This is the place that command line switches of /a /o /p are all supported.


    Function set_output_params
    Include file OUTDEV_R.H
    Prototype void set_output_params( void )
    Remarks This routine opens the GLOBAL var FILE *output_device to point to disk, tube or printer depending on the user's command line switches.


    Function close_output_device
    Include file OUTDEV_R.H
    Prototype void close_output_device( void )
    Remarks Will also send a FF to the printer if necessary and is smart enough to not close the stdout.


    Table of Contents Function Index

    STD_CODE.C

    This module is the home for all user-interface, standard product routines.


    Function my_fprintf
    Include file STD_CODE.H
    Prototype void my_fprintf( char *out_str , int start_col )
    Remarks Hook back to here for all product output, this gives us the chance to play with the output before dumping to the output_device (out_str is expected to be ready to go).


    Function expand_tabs_in_str_2_spaces
    Include file STD_CODE.H
    Prototype void expand_tabs_in_str_2_spaces( int tab , int start_col , char *src , char *dest )
    Remarks Remove hardware tabs and replace/expand to spaces for consistent displays.


    Function _strtime
    Include file STD_CODE.H
    Prototype void _strtime( char *time_buff )
    Remarks These are useful little Microsoft routines that TURBOC didn't support. Warning - you will probably need to define the environment variable TZ (for Time Zone). Look up the routine tzset() in your C manual for more info.


    Function _strdate
    Include file STD_CODE.H
    Prototype void _strdate( char *date_buff )
    Remarks These are useful little Microsoft routines that TURBOC didn't support.


    Function dump_copyright_notices
    Include file STD_CODE.H
    Prototype void dump_copyright_notices( char *begin_str )
    Remarks Build and dump a copyright banner with a date string in column 72 to the output_device (& maybe stdout). If you write a program for distribution you MUST change this banner to your name or company name.


    Function compress_cmd_ln
    Include file STD_CODE.H
    Prototype void compress_cmd_ln( char *cmd_ln )
    Remarks Take the raw MSDOS user command line and grab the program_path and the target_drive from the 1st argument. If the user cmd_ln is longer than 70 characters, copy and drop the program_path from the cmd_ln.


    Function get_drive_num_from_str
    Include file STD_CODE.H
    Prototype int get_drive_num_from_str( char *program_path_str )
    Remarks Grab the drive code off from a program_path and return as number for BIOS calls.


    Function report_fatal_error
    Include file STD_CODE.H
    Prototype void report_fatal_error( char *err_str )
    Remarks Abandon all hope - ye who enter here , Thou shall never return (will hook back to the main programs local_exit()).


    Function rpt_debug_msg
    Include file STD_CODE.H
    Prototype void rpt_debug_msg( char *msg )
    Remarks Dump a trace message to stderr if debug_flag set.


    Function rpt_msg_n_status
    Include file STD_CODE.H
    Prototype void rpt_msg_n_status( char *msg , int status )
    Remarks Dump a trace message with status value to stderr if debug_flag set.


    Function dspy_compile_version
    Include file STD_CODE.H
    Prototype void dspy_compile_version( int exit_code )
    Remarks Report program name & version, which compiler & compile date/time.


    Function dump_banner_2_output_device
    Include file STD_CODE.H
    Prototype void dump_banner_2_output_device( char *comment )
    Remarks Dump a banner comment with a timestamp to output_device (& maybe stdout). Also dump program version & compile info, suitable as exit rundown.


    Function echo_2_stdout_if_necessary
    Include file STD_CODE.H
    Prototype void echo_2_stdout_if_necessary( char *important_msg )
    Remarks Dump a important msg to the output_device and force to stdout also if output_device != stdout.


    Function chk_if_we_are_superuser
    Include file STD_CODE.H
    Prototype int chk_if_we_are_superuser( void )
    Remarks This routine shows a way to allow run-time program privileges in MSDOS which doesn't directly support process privileges. This could be used to remotely turn-on maintenance or debug modes in programs on a customer's box.


    Function cmd_ln_args_2_str
    Include file STD_CODE.H
    Prototype void cmd_ln_args_2_str( char *str , int argc , char **argv )
    Remarks Concatenate the program command line arguments into a single string.


    Function dump_cmd_ln_2_output_device
    Include file STD_CODE.H
    Prototype void dump_cmd_ln_2_output_device( char *str )
    Remarks A simple add a \n and flush.


    Function dump_TS_cmd_ln_2_output_device
    Include file STD_CODE.H
    Prototype void dump_TS_cmd_ln_2_output_device( char *str )
    Remarks Build a nice banner string with a time stamp in column 72.


    Function chk_if_help_was_requested
    Include file STD_CODE.H
    Prototype void chk_if_help_was_requested( void )
    Remarks If the help_flag is set - use OLM to display the program's doc file.


    Function dspy_video_buffered_data
    Include file STD_CODE.H
    Prototype void dspy_video_buffered_data( void )
    Remarks If buffer_video_output is set - use OLM to display the program report file for the user.


    Function olm_a_file
    Include file STD_CODE.H
    Prototype void olm_a_file( char *file_name )
    Remarks A simple wrapped routine for OLM file viewing from inside a program.


    Function string_copy
    Include file STD_CODE.H
    Prototype char *string_copy( char *str )
    Remarks This a functional clone of the normal C library function strdup, except this one uses the wrapped version of calloc().


    Function calc_avg
    Include file STD_CODE.H
    Prototype float calc_avg( float total , int divisor )
    Remarks A Q & D because MSC is unforgiving about divides by zero.


    Function calc_percentage
    Include file STD_CODE.H
    Prototype float calc_percentage( UINT total , UINT count )
    Remarks A Q & D because MSC is unforgiving about divides by zero.


    Function direct_disk_read_fe
    Include file STD_CODE.H
    Prototype int direct_disk_read_fe( char *buff , int drive , int start_sector , int num_of_sectors )
    Remarks Front-end the the Int 25h direct_disk_read. The front-end supports status checking, read retrys & device resets. This is the Microsoft version.


    Function direct_disk_read_fe
    Include file STD_CODE.H
    Prototype int direct_disk_read_fe( char *buff , int drive , int start_sector , int num_of_sectors )
    Remarks And this is the TurboC version.


    Function init_scrolled_region
    Include file STD_CODE.H
    Prototype void init_scrolled_region( int l_row , int l_col , int r_row , int r_col )
    Remarks Initialize the module static scroll variables. The region is defined by the upper left & lower right corners.


    Function update_scrolled_region
    Include file STD_CODE.H
    Prototype void update_scrolled_region( char *str )
    Remarks Dump the user string into the previous init-ed scrolled region and scroll it if necessary.


    Function advance_scrolled_region
    Include file STD_CODE.H
    Prototype void advance_scrolled_region( void )
    Remarks Advance the scroll_ptr through the scrolled region and scroll data out up the top.


    Function loop_opt
    Include file STD_CODE.H
    Prototype #pragma loop_opt( off )
    Remarks


    Function millisecond_delay
    Include file STD_CODE.H
    Prototype void millisecond_delay( UINT delay )
    Remarks A QND cpu timewaster.


    Function loop_opt
    Include file STD_CODE.H
    Prototype #pragma loop_opt( on )
    Remarks


    Table of Contents Function Index

    GEN_UTL.C - GENeral UTiLity routines

    A few utility routines that don't need a whole module.


    Function ld_ascii_data_file
    Include file GEN_UTL.H
    Prototype void ld_ascii_data_file( char *file_name , FPTR process_routine , BOOL echo_flag )
    Remarks Load a ASCII file and call a process routine for each line of the file. Set echo_flag to TRUE to get a debug dump to scr. If the process routine wants to know where it is it should IMPORT and reference ASCII_line_num. The process routine should expect one parameter, a char *. Lines beginning with a COMMENT_CHAR (currently defined as "#") will not to sent to the process_routine.


    Function dot_tty
    Include file GEN_UTL.H
    Prototype void dot_tty( void )
    Remarks Just a QND to dump a . to the tube so the user doesn't think that the program has died.


    Function time_stamp
    Include file GEN_UTL.H
    Prototype char *time_stamp( void )
    Remarks Get current full 26 character long date & time str from asctime.


    Function my_calloc
    Include file GEN_UTL.H
    Prototype void *my_calloc( UINT bytes_needed )
    Remarks A wrapped version of calloc, out of memory is handled as a fatal.


    Function my_farcalloc
    Include file GEN_UTL.H
    Prototype void far *my_farcalloc( ULONG bytes_needed )
    Remarks A wrapped version of farcalloc, out of memory is handled as a fatal.


    Function chk_4_file
    Include file GEN_UTL.H
    Prototype int chk_4_file( char *target_file )
    Remarks Check 4 user requested file, return TRUE if found, target_file may include drive and directory path info.


    Function my_unlink
    Include file GEN_UTL.H
    Prototype void my_unlink( char *file_name )
    Remarks A wrapped version of unlink. Will jump to local_exit() unless GLOBAL var return_from_lib_error == TRUE.


    Function init_ran
    Include file GEN_UTL.H
    Prototype void init_ran( void )
    Remarks This routine is used to generate a random seed for init-ing srand(), then it calls rand() a random number of times. After calling this routine you can count on be in a random location in the pseudorandom number sequence generated by rand().


    Function random_int
    Include file GEN_UTL.H
    Prototype int random_int( int max_integer )
    Remarks Return a random_int in the range of 0 to max_integer.


    Table of Contents Function Index

    PRC_CNFG.C - PRoCess run-time CoNFiGuration file

    A set of routines to read an ASCII configuration file and process it's data and store the info back in the caller's main() module. The user program must allocate a CNF cnf_table[] and a cnf_table_size. If config_file == NULL then use the default config file from prc_cnfg.h. Normal use would be like - ld_ascii_data_file( get_config_file(),process_config_file,debug_flag ) somewhere very early in the program activation. The normal default is to ignore non-matches to the cnf_table but you can turn-on error reporting by setting the GLOBAL var cnf_report_error to TRUE.


    Function get_config_file
    Include file PRC_CNFG.H
    Prototype char *get_config_file( void )
    Remarks Return either a user provided config_file name or the module subsystem default name.


    Function process_config_file
    Include file PRC_CNFG.H
    Prototype void process_config_file( char *input_line )
    Remarks Called by ld_ascii_data_file to process a individual config file entry. After preping the input_line, it will call process_one_config_entry.


    Function process_one_config_entry
    Include file PRC_CNFG.H
    Prototype int process_one_config_entry( char *input_line )
    Remarks Lookup, validate and store one entry.


    Function lookup_config_index
    Include file PRC_CNFG.H
    Prototype int lookup_config_index( char *token )
    Remarks Check the file token string against the CNF table. Return table index if found else return cnf_table_size as not found.


    Function normal_cnf_table_store
    Include file PRC_CNFG.H
    Prototype void normal_cnf_table_store( int cnf_index , char *str )
    Remarks Store a config entry back into the caller's data space.


    Table of Contents Function Index

    GETARGS.C Command line argument processor


    Function getargs
    Include file GETARGS.H
    Prototype int getargs( int argc , char **argv , ARG *tbl_ptr , int tbl_size )
    Remarks Process command line arguments. Stripping all command line switches out of argv. Return a new argc. If an error is found local_exit(1) is called (getargs won't return) and a usage message is printed showing all arguments in the table.


    Function stoi
    Include file GETARGS.H
    Prototype int stoi( register char **instr )
    Remarks stoi is a more powerful version of atoi. Convert string to integer. If string starts with 0x it is interpreted as a hex number, else if it starts with a 0 it is octal, else it is decimal. Conversion stops on encountering the first character which is not a digit in the indicated radix. *instr is updated to point past the end of the number


    Function setarg
    Include file GETARGS.H
    Prototype static char *setarg( ARG *argp , char *linep )
    Remarks Set an argument , argp points at the argument table entry corresponding to *linep. Return linep , updated to point past the argument being set.


    Function findarg
    Include file GETARGS.H
    Prototype static ARG *findarg( int c , ARG *tbl_ptr , int tbl_size )
    Remarks Return pointer to argument table entry corresponding to c ( or 0 if c isn't in the table ).


    Function pr_usage
    Include file GETARGS.H
    Prototype static void pr_usage( ARG *tbl_ptr , int tbl_size )
    Remarks Print the arg_tbl in the form: -< arg > < errmsg > (value is < *variable > )


    Table of Contents Function Index

    ERR_MSGS.C

    Error msgs and constants for the file access and cmd line configuration routines.


    Function report_error_n_exit
    Include file ERR_MSGS.H
    Prototype void report_error_n_exit( int err_num )
    Remarks Dump the error message ( err_msgs[ err_num ] ) to stderr then call local_exit.


    Table of Contents Function Index

    C_DATE_R.C - Convert and validate DATE Routines.

    Date formats supported are MM/DD/YY, European DD/MM/YY, and YYMMDD strings, YYMMDD floats and UINT julians. There are conversion routines to do any translation. The julian conversion routines are in the julian module J_DATE_R.C.


    Function validate_date_field
    Include file C_DATE_R.H
    Prototype int validate_date_field( char *date_field )
    Remarks Front-end to validate_MM_DD_YY. This routine supports lazy user input, given MM/DD the routine will add the current year. The year is saved and carried over from call to call so you could enter 11/12/91 then 11/13 and have 91 added on. The modified str is then checked by validate_MM_DD_YY.


    Function validate_MM_DD_YY
    Include file C_DATE_R.H
    Prototype int validate_MM_DD_YY( char *date_str )
    Remarks Validate the month and day fields of a MM/DD/YY date str. Return TRUE if valid else FALSE (all INVALID - 2/29/83 | 14/02/91 | 10/44/99 ).


    Function cnvt_MM_DD_YY_2_flt
    Include file C_DATE_R.H
    Prototype float cnvt_MM_DD_YY_2_flt( char *date_str )
    Remarks Convert a MM/DD/YY date string into a float of YYMMDD.


    Function cnvt_DD_MM_YY_2_flt
    Include file C_DATE_R.H
    Prototype float cnvt_DD_MM_YY_2_flt( char *date_str )
    Remarks Convert a European style DD/MM/YY date string into a float of YYMMDD.


    Function get_date_substr
    Include file C_DATE_R.H
    Prototype static char *get_date_substr( char *src , char *dest )
    Remarks Simple worker parse routine for cnvt_MM_DD_YY_2_flt.


    Function cnvt_YYMMDD_flt_2_MM_DD_YY
    Include file C_DATE_R.H
    Prototype char *cnvt_YYMMDD_flt_2_MM_DD_YY( float flt_date )
    Remarks Convert a YYMMDD float into a MM/DD/YY date string.


    Function cnvt_YYMMDD_flt_2_DD_MM_YY
    Include file C_DATE_R.H
    Prototype char *cnvt_YYMMDD_flt_2_DD_MM_YY( float flt_date )
    Remarks Convert a YYMMDD float into a Euro style DD/MM/YY date string.


    Function cnvt_YYMMDD_str_2_flt
    Include file C_DATE_R.H
    Prototype float cnvt_YYMMDD_str_2_flt( char *date_str )
    Remarks Convert a YYMMDD date str into a YYMMDD float.


    Function cnvt_YYMMDD_str_2_MM_DD_YY
    Include file C_DATE_R.H
    Prototype char *cnvt_YYMMDD_str_2_MM_DD_YY( char *date_str )
    Remarks Convert a YYMMDD date str into a MM/DD/YY date str


    Function cnvt_MM_DD_YY_2_YYMMDD_str
    Include file C_DATE_R.H
    Prototype char *cnvt_MM_DD_YY_2_YYMMDD_str( char *date_str )
    Remarks Convert a MM/DD/YY date str into a YYMMDD date str


    Function cnvt_YYMMDD_flt_2_YYMMDD_str
    Include file C_DATE_R.H
    Prototype char *cnvt_YYMMDD_flt_2_YYMMDD_str( float flt_date )
    Remarks Convert a YYMMDD float date into a YYMMDD date str


    Function constant_length_date
    Include file C_DATE_R.H
    Prototype char *constant_length_date( char *date_str )
    Remarks Well not quite any more - expand day and month fields to 2 digits and return the year field un-touched.


    Function get_field_from_YYMMDD_flt
    Include file C_DATE_R.H
    Prototype int get_field_from_YYMMDD_flt( float flt_date , int which_field )
    Remarks Fetch a field from a YYMMDD float style date and return it as an int. This routine is front-ended by 3 macros to fetch each individual field. The macros just need a date as a argument. They are defined in C_DATE_R.H and are get_YY_from_YYMMDD_flt( fd ), get_MM_from_YYMMDD_flt( fd ) and get_DD_from_YYMMDD_flt( fd )..


    Table of Contents Function Index

    J_DATE_R.C - Julian_DATE_Routines

    Some ANSI C Julian date routines.


    Function cnvt_julian_date_2_str
    Include file J_DATE_R.H
    Prototype char *cnvt_julian_date_2_str( UINT julian , int str_type )
    Remarks Convert a julian date into either a MM/DD/YY or YYMMDD style date str depending on str_type. This routine is front-ended by 2 routines - cnvt_julian_date_2_YYMMDD( jd ) and cnvt_julian_date_2_MM_DD_YY( jd ) which will worry about setting the string type. The returned str is built in a module static char array. Each new call will overwrite the array. If the year is between 1900 & 1999 then 1900 will be subtracted.


    Function cnvt_julian_date_2_YYMMDD
    Include file J_DATE_R.H
    Prototype char *cnvt_julian_date_2_YYMMDD( UINT julian_date )
    Remarks Request YYMMDD date str style from cnvt_julian_date_2_str().


    Function cnvt_julian_date_2_MM_DD_YY
    Include file J_DATE_R.H
    Prototype char *cnvt_julian_date_2_MM_DD_YY( UINT julian_date )
    Remarks Request DD/MM/YY date str style from cnvt_julian_date_2_str().


    Function julian_date
    Include file J_DATE_R.H
    Prototype UINT julian_date( char *date_str )
    Remarks Convert a date str MM/DD/YY (assumed to have been already validated) into a julian date.


    Function cnvt_julian_date_2_YYMMDD_flt
    Include file J_DATE_R.H
    Prototype float cnvt_julian_date_2_YYMMDD_flt( UINT julian_date )
    Remarks Convert a julian into a float.


    Function day_of_the_week
    Include file J_DATE_R.H
    Prototype int day_of_the_week( UINT julian_num ) /* Sun=0 , Mon=1 ... Sat=6 */
    Remarks Convert a julian date into a day of the week offset.


    Function get_jdate_from_user
    Include file J_DATE_R.H
    Prototype UINT get_jdate_from_user( char *prompt_str )
    Remarks Will prompt the user with the prompt_str, fetch his input, validate it, if valid then return the julian date else Invalid date msg to the user and loop till he gets it right.


    Table of Contents Function Index

    MRK_DAYR.C - MaRKet_DAY_Routines

    These routines will support hidden holiday tracking providing a way to check a julian date to determine if the market will be open.


    Function is_mrk_day
    Include file MRK_DAYR.H
    Prototype int is_mrk_day( UINT j_date )
    Remarks Return TRUE if the target julian date is not a Saturday, Sunday or a market holiday else FALSE. This routine also calls chk_if_holiday().


    Function chk_if_holiday
    Include file MRK_DAYR.H
    Prototype int chk_if_holiday( UINT j_date )
    Remarks Return TRUE if the target julian date is market holiday else FALSE. Calling this routine will automatically load the holiday file.


    Function ld_holiday_file
    Include file MRK_DAYR.H
    Prototype static void ld_holiday_file()
    Remarks Load the holiday in local module memory.


    Function process_holiday_rec
    Include file MRK_DAYR.H
    Prototype static void process_holiday_rec( char *holiday_str )
    Remarks Called by ld_ascii_data_file to process an individual holiday record from the holiday file.


    Function store_holiday_rec
    Include file MRK_DAYR.H
    Prototype static void store_holiday_rec( UINT holiday_j )
    Remarks Store a holiday in module memory in julian.


    Table of Contents Function Index

    DOS_TIME.C

    A collection of MSDOS time and date routines.


    Function get_time_in_DOS_format
    Include file DOS_TIME.H
    Prototype UINT get_time_in_DOS_format( void )
    Remarks Get the 16 bit MSDOS time value.


    Function dostime_2_str
    Include file DOS_TIME.H
    Prototype char *dostime_2_str( UINT dostime , char *buff )
    Remarks Convert a 16 MSDOS time value into a HH:MM:SS str in the user buffer.


    Function tm_2_MM_DD_YY
    Include file DOS_TIME.H
    Prototype void tm_2_MM_DD_YY( struct tm *time , char *date_str )
    Remarks Convert a DOS tm struct to a MM/DD/YY str in the user's buffer.


    Function cnvt_tm_struct_2_dostime
    Include file DOS_TIME.H
    Prototype long cnvt_tm_struct_2_dostime( struct tm *time )
    Remarks Convert tm struct to a 32 bit MSDOS date/time value.


    Function print_tm_struct
    Include file DOS_TIME.H
    Prototype void print_tm_struct( struct tm *time )
    Remarks Print a tm struct to stdout.


    Function clear_tm_struct
    Include file DOS_TIME.H
    Prototype void clear_tm_struct( struct tm *time )
    Remarks Well not exactly clear , set the tm struct to MSDOS base time/date.


    Table of Contents Function Index

    DOS_CODE.C

    This module contains various low level DOS disk interface routines. Warning - routines in this module can fetch things that if written back to disk - Could (and if Murphy has anything to say about it WILL) mung things up VERY bad. So don't write these back unless you know what you are doing. Ok you been warned, it's your foot.


    Function load_disk_boot_record
    Include file DOS_CODE.H
    Prototype void load_disk_boot_record( int drive )
    Remarks Load the boot record for the requested drive and calc the start of the root directory. Drive is absolute drive number (not logical).


    Function get_logical_sector_number
    Include file DOS_CODE.H
    Prototype UINT get_logical_sector_number( UINT cluster )
    Remarks Convert disk cluster number into logical sector numbers.


    Function get_dir_record
    Include file DOS_CODE.H
    Prototype DIR_REC *get_dir_record( char *file_name_n_ext , int start_sector , int root_flag )
    Remarks This routine will read and search a MSDOS directory file for a target entry. The disk sector of the directory file must be given but the search can be either the root dir or any sub-directory. Sub-directory searchs are limited to the cluster of the directory.


    Function load_disk_info_via_ioctl
    Include file DOS_CODE.H
    Prototype void load_disk_info_via_ioctl( void )
    Remarks Use the Int 21 IOCTL get device parameters call to fetch disk info.


    Function get_dos_version
    Include file DOS_CODE.H
    Prototype int get_dos_version( void )
    Remarks return XY where X - major , Y - minor version levels.


    Function call_int21_get_disk_data
    Include file DOS_CODE.H
    Prototype void call_int21_get_disk_data( void )
    Remarks Call the old Int 21 get disk data function.


    Table of Contents Function Index

    CNVTBOND.C

    Conversion routines for handling T-Bond data.


    Function cnvt_tbond_data_rec_2_decimal
    Include file CNVTBOND.H
    Prototype void cnvt_tbond_data_rec_2_decimal( DATA_REC *data_ptr )
    Remarks Convert all price data fields in the caller's DATA_REC from T-Bond 32's style to T-Bond decimal style.


    Function cnvt_tbond_data_rec_dec_to_32
    Include file CNVTBOND.H
    Prototype void cnvt_tbond_data_rec_dec_to_32( DATA_REC *data_ptr )
    Remarks Convert all price data fields in the caller's DATA_REC from T-Bond decimal style to T-Bond 32's style.


    Function cnvt_tbond_2_decimal
    Include file CNVTBOND.H
    Prototype float cnvt_tbond_2_decimal( float bond_quote )
    Remarks Convert a T-Bond 32's data value into a decimal format. 88.08 -> 88.25


    Function cnvt_tbond_decimal_2_normal
    Include file CNVTBOND.H
    Prototype float cnvt_tbond_decimal_2_normal( float bond_quote )
    Remarks Convert a T-Bond decimal data value back into a 32's style. 87.75 -> 87.24


    Table of Contents Function Index

    UTLSTR_R.C - Utility STRing Routines

    A collection of useful string manipulation routines (they all expect NULL terminated strs).


    Function eat_trailing_white_space
    Include file UTLSTR_R.H
    Prototype void eat_trailing_white_space( char *str )
    Remarks Delete trailing white space from a str.


    Function cnvt_nl_2_null
    Include file UTLSTR_R.H
    Prototype void cnvt_nl_2_null( char *str )
    Remarks Replace all embedded newlines in source str with \000 (yielding substrings in the main string).


    Function cnvt_line_to_uppercase
    Include file UTLSTR_R.H
    Prototype void cnvt_line_to_uppercase( char *str )
    Remarks Convert all characters in the string to uppercase.


    Function cnvt_line_to_lowercase
    Include file UTLSTR_R.H
    Prototype void cnvt_line_to_lowercase( char *str )
    Remarks Convert all characters in the string to lowercase.


    Function insert_str_into_str
    Include file UTLSTR_R.H
    Prototype void insert_str_into_str( char *dest , char *insert_str , int offset )
    Remarks WARNING - this routine will do a detructive insert a str into the destination string since dest will get NULL terminated after the end of insert str.


    Function copy_str_n_blank_pad
    Include file UTLSTR_R.H
    Prototype void copy_str_n_blank_pad( char *src , char *dest , int len )
    Remarks Copy source string to destination and pad with spaces " " till user requested length. WARNING - this routine does not NULL terminate the destination string.


    Function validate_with_str_array
    Include file UTLSTR_R.H
    Prototype int validate_with_str_array( char *validate_strs[] , char *target , int cnt )
    Remarks Compare a target string to a array of strings. Return array index if matched else cnt as not found flag. This routine is useful for validating command verbs or user input.


    Function validate_boolean_answer
    Include file UTLSTR_R.H
    Prototype int validate_boolean_answer( char *str )
    Remarks Return TRUE if str is a valid_true [ "Y" | "YES" | "T" | "TRUE" ] else FALSE. This routine is layered on validate_with_str_array().


    Function match_str_with_wildcard_support
    Include file UTLSTR_R.H
    Prototype int match_str_with_wildcard_support( char *match_str , char *source )
    Remarks Support embedded ?'s as any single char.


    Table of Contents Function Index

    S_PARSER.C - Simple PARSE Routines

    A couple very simple ANSI C parse and identify routines. These are meant to do white space parses on a str to support simple vocabularies or simple destructive converts. For complex vocabularies you should use YACC or BISON.


    Function return_next_token_str
    Include file S_PARSER.H
    Prototype char *return_next_token_str( char *source_str , int terminate_str_flag )
    Remarks This routine returns the next white space delimited token str from a source_str. If terminate_str_flag == TRUE then the token str is NULL terminated. This routine is init-ed on the first call by providing a source_str on the call. On future calls pass NULL instead of a str to fetch sequential tokens from the original str.


    Function chk_cmd_verb_table
    Include file S_PARSER.H
    Prototype int chk_cmd_verb_table( char *parsed_verb , CMD_VB cmd_verb_tbl[] , int tbl_size )
    Remarks Check a parsed_verb against a command_verb_table, if found return the function code found in the verb, else return MAX table as not found.


    Table of Contents Function Index

    MY_DIR.C

    A few wrapped MSDOS directory functions.


    Function my_mkdir
    Include file MY_DIR.H
    Prototype void my_mkdir( char *path )
    Remarks A wrapped version of mkdir. Will jump to local_exit() unless GLOBAL var return_from_lib_error == TRUE.


    Function my_chdir
    Include file MY_DIR.H
    Prototype void my_chdir( char *dir_str )
    Remarks A wrapped version of chdir. Will jump to local_exit() unless GLOBAL var return_from_lib_error == TRUE.


    Function my_rmdir
    Include file MY_DIR.H
    Prototype void my_rmdir( char *dir_str )
    Remarks A wrapped version of rmdir. Will jump to local_exit() unless GLOBAL var return_from_lib_error == TRUE.


    Table of Contents Function Index

    GRX.C

    This module contains the EGA mode charting subsystem. These are the level 2 & 3 functions.

    TDF_Lib buyers - if one wished to port this package to a different graphics platform like BGI all you would have to do is rewrite &| front-end &| simulate the level 1 functions and variables in SM_GRX.C & SM_GRX2.ASM, the level 2 functions in this module will require a look (and maybe some work) and then the level 3 functions will run clean.


    Function draw_cmd_chart
    Include file GRX.H
    Prototype GRFX *draw_cmd_chart( int cht_size , int cht_flags , int data_cnt , void *data , char *label )
    Remarks Draw an initial bar or line chart. Call this routine first to get a new GRFX structure complete with scr sizes & scale factors.


    Function overlay_line_plot
    Include file GRX.H
    Prototype void overlay_line_plot( GRFX *old_chart_ptr , float *data , int line_color )
    Remarks Overlay a indicator on an existing bar or line chart. Since this doesn't recalc the scale factors you must make the first call to draw_cmd_chart with the largest range indicator.


    Function new_grfx_struct
    Include file GRX.H
    Prototype GRFX *new_grfx_struct( int cht_size )
    Remarks Allocate and initialize a new GRFX structure to the cht_size.


    Function calc_scr_size_constants
    Include file GRX.H
    Prototype void calc_scr_size_constants( void )
    Remarks Calculate the chart sizes based on current EGA resolution.


    Function store_1_scr_sizes
    Include file GRX.H
    Prototype void store_1_scr_sizes( int idx , int xmin , int ymin , int xmax , int ymax )
    Remarks Worker store routine for calc_scr_size_constants().


    Function draw_empty_chart
    Include file GRX.H
    Prototype void draw_empty_chart( void )
    Remarks Draw a virgin chart.


    Function calc_dt_n_axis_scale_factors
    Include file GRX.H
    Prototype int calc_dt_n_axis_scale_factors( void )
    Remarks Calculate the data range, plot scale factors and axis move increments. Return TRUE if ok to plot else FALSE if not.


    Function build_axis_incs
    Include file GRX.H
    Prototype void build_axis_incs( void )
    Remarks Calculate the axis plot increments based on number of data points and number of scaling rows.


    Function calc_dt_range
    Include file GRX.H
    Prototype void calc_dt_range( void )
    Remarks Calculate the data range then calc the scaling increment and plot scaling factor.


    Function set_high_lows
    Include file GRX.H
    Prototype void set_high_lows( float *high_ptr , float *low_ptr , int loop_cnt )
    Remarks Find the highest_high and the lowest_low in the data series and store them back into the caller's memory.


    Function calc_range
    Include file GRX.H
    Prototype void calc_range( int interval_index , int loop_cnt )
    Remarks Find the best fit scale interval for the data series. This routine will call itself recursively with loop_cnt in control of when to bail out.


    Function set_plot_range
    Include file GRX.H
    Prototype void set_plot_range( float min_range , float max_range )
    Remarks Use this routine to force a chart to be plotted and scaled to your specified min and max range values. This routine must be called before the call to draw_cmd_chart() and the provided values are only good for one call to draw_cmd_chart().


    Function reset_temp_grfx_vars
    Include file GRX.H
    Prototype void reset_temp_grfx_vars( void )
    Remarks Reset the per-chart call booleans.


    Function round_as_int
    Include file GRX.H
    Prototype float round_as_int( float float_data , float interval , int fudge_factor )
    Remarks Convert a float to an integer, round it, then convert it back to a float and return it.


    Function align_1st_bar
    Include file GRX.H
    Prototype void align_1st_bar( void )
    Remarks Position to the 1st bar plot loc along the x axis.


    Function adv_x_axis_plot_point
    Include file GRX.H
    Prototype void adv_x_axis_plot_point( void )
    Remarks Advance the x-axis plotting loc.


    Function plot_high_low_bar
    Include file GRX.H
    Prototype void plot_high_low_bar( DATA_REC *bar_ptr )
    Remarks Plot a high/low/close bar for the given DATA_REC.


    Function get_y_plot
    Include file GRX.H
    Prototype int get_y_plot( float y_float )
    Remarks Return the calculated y plot location for the given data value.


    Function label_cmd_chart
    Include file GRX.H
    Prototype void label_cmd_chart( char *label )
    Remarks Write a label across the top of the chart.


    Function label_y_axis
    Include file GRX.H
    Prototype void label_y_axis( void )
    Remarks Write the row prices out along the y axis.


    Function plot_DATA_REC_data
    Include file GRX.H
    Prototype void plot_DATA_REC_data( void )
    Remarks Plot all the DATA_REC data bars as high/low/close bars.


    Function plot_float_data
    Include file GRX.H
    Prototype void plot_float_data( void )
    Remarks Plot all the data as a indicator line. If the data in the float array == IND_VAL_INVALID it will be assumed as indicator not up to speed and not be output. If grfx_ptr->cht_flags has the GRFX_FG_IND_HISTOGRAM bit hit guess what you'll get.


    Function get_month_str
    Include file GRX.H
    Prototype char *get_month_str( int mth_index )
    Remarks A qnd to translate the month number into the text str.


    Function label_x_axis_as_date
    Include file GRX.H
    Prototype void label_x_axis_as_date( void )
    Remarks Write date labels along the x axis.


    Function label_x_axis_as_date_style2
    Include file GRX.H
    Prototype void label_x_axis_as_date_style2( void )
    Remarks Write date labels along the x axis from a intraday data series. This routine will be called by label_x_axis_as_date() if the data series beginning date is < 01/01/01 (in YYMMDD style). This routine then expects the date field to contain ( ( day_num * 60 ) + bar_num ).


    Function label_ind_x_axis_with_date
    Include file GRX.H
    Prototype void label_ind_x_axis_with_date( DATA_REC *data_ptr )
    Remarks When we draw a indicator chart the float data-array doesn't have a date field, so if we cheat and after the first indicator chart is drawn we call here with the raw DATA_REC data series we can use the module GLOBAL GRFX *ptr and label the axis.


    Function plot_volume_bars
    Include file GRX.H
    Prototype void plot_volume_bars( void )
    Remarks Add the volume bars to a GRX_FG_DATA_REC bar chart.


    Function plot_open_int_line
    Include file GRX.H
    Prototype void plot_open_int_line( void )
    Remarks Overlay a open interest line over the volume bars on a GRX_FG_DATA_REC bar chart. If grfx_add_vol_bars == FALSE or DATA_REC->open_int == 0.0 then no open_int plot.


    Function set_equivolume_scale_factors
    Include file GRX.H
    Prototype void set_equivolume_scale_factors( void )
    Remarks Calc the x axis volume step for a equivolume style chart.


    Function draw_y_line
    Include file GRX.H
    Prototype void draw_y_line( float y_value , int line_color )
    Remarks Draw a line of line_color across the chart at y_value location.


    Function Graphics_on
    Include file GRX.H
    Prototype int Graphics_on( void )
    Remarks Initialize the GRX subsystem.


    Function Graphics_off
    Include file GRX.H
    Prototype int Graphics_off( void )
    Remarks Turn off EGA graphics mode and set to BIOS int 10h - mode 3 (text mode color 80 column).


    Function GRX_grid
    Include file GRX.H
    Prototype void GRX_grid( int x_start , int y_start , int x_stop , int y_stop , int num_of_cols , int num_of_rows , int box_the_grid )
    Remarks Multi-function grid and box draw routine. This routine is front-ended by the following macros in GRX.H for various sub-functions, grid ( draws a grid, boxed grid ( draw a grid and boxes it ), hortz_dsh_lns ( draws a series of horizontal dashed lines bounded by the x/y coordinates ) and vert_dsh_lns ( same as the last except vertical ). The x/y coordinates are for the upper left corner ( x_start , y_start ) and the lower right corner ( x_stop , y_stop ) of the desired area.


    Function GRX_box
    Include file GRX.H
    Prototype void GRX_box( int x_start , int y_start , int x_stop , int y_stop )
    Remarks A simple draw a box around from upper left corner ( x_start , y_start ) to the lower right corner ( x_stop , y_stop ) of the desired area.


    Function set_x_inc
    Include file GRX.H
    Prototype void set_x_inc( int x_start , int x_stop , int num_of_cols )
    Remarks Calculate the x axis increment per data point.


    Function set_y_inc
    Include file GRX.H
    Prototype void set_y_inc( int y_start , int y_stop , int num_of_rows )
    Remarks Calculate the y axis increment per scale row.


    Function tick_x_axis
    Include file GRX.H
    Prototype void tick_x_axis( int x_start , int y_loc , int tick_dir , int nolast_tick , int tick_length , int tick_interval )
    Remarks Draw a series of x axis tick marks.


    Function tick_y_axis
    Include file GRX.H
    Prototype void tick_y_axis( int y_start , int x_loc , int tick_dir , int nolast_tick , int tick_length , int tick_interval )
    Remarks Draw a series of y axis tick marks.


    Table of Contents Function Index

    SM_GRX.C -

    This is the C code hacked into a mini graphics library from the Aztec library. This is just level 1 stuff. All that is supported is Set mode (just EGA) , set color , draw line and plot point functions. GRX.C will support level 2 and level 3 functions.


    Function mode
    Include file SM_GRX.H
    Prototype void mode( int val )
    Remarks Set graphics mode.


    Function color
    Include file SM_GRX.H
    Prototype void color( int c )
    Remarks Set the active color.


    Function color_n_return_cur
    Include file SM_GRX.H
    Prototype int color_n_return_cur( int c )
    Remarks Set the active color and return the old color.


    Function set_line_2_dashed
    Include file SM_GRX.H
    Prototype void set_line_2_dashed( int dash_pattern )
    Remarks Set the indicator line to a dash pattern.


    Function set_line_2_solid
    Include file SM_GRX.H
    Prototype void set_line_2_solid( void )
    Remarks Set indicator line to solid.


    Table of Contents Function Index

    SM_GRX2.ASM - low level graphics routines

    This is the asm code hacked into a mini graphics library from the Aztec library. This is just level 1 stuff. All that is supported is Set mode (just EGA) , set color , draw line and plot point functions. GRX.C will still support level 2 & 3 functions. The reason I still use this is that it is tiny and fast (not to mention simple).

    scr_call( ax , bx , cx , dx )
    point( x , y )
    line( src_x , src_y , dest_x , dest_y )
    lineto( dest_x , dest_y ) (from current position)


    Function scr_call
    Include file GRX.H
    Prototype int scr_call( int ax , int bx , int cx , int dx )
    Remarks Load the 4 registers and do a video interrupt. The return value is what int 10h returns in ax.


    Function ega_plot_pt
    Include file GRX.H
    Prototype void ega_plot_pt( void )
    Remarks Internal ega_plot_pt() routine. This is the lowest level code, tell the EGA controller to plot a pixel. This routine was modified from BYTE (10/85) code


    Function chk_dash_state
    Include file GRX.H
    Prototype void chk_dash_state( void )
    Remarks a Q & D to skip every other dot nope use a skip_cnt nope now use an hardware bit rotate


    Function _pnt
    Include file GRX.H
    Prototype void _pnt( void )
    Remarks Internal _pnt() routine. Just plot a pixel. Everybody uses this routine to draw.


    Function _inline
    Include file GRX.H
    Prototype void _inline( void )
    Remarks Internal line function, everybody comes here to draw the line


    Function point
    Include file GRX.H
    Prototype void point( int x , int y )
    Remarks Plot a point at xy.


    Function line
    Include file GRX.H
    Prototype void line( int src_x , int src_y , int dest_x , int dest_y )
    Remarks Draw a line from src_x/src_y to dest_x/dest_y.


    Function lineto
    Include file GRX.H
    Prototype void lineto( int dest_x , int dest_y )
    Remarks Draw a line from current position to dest_x/dest_y.


    Table of Contents Function Index

    VECT_TXT.ASM

    A procedure to write a str to a graphics display using a stroked font set.


    Function Vector_text
    Include file GRX.H
    Prototype void Vector_text( char *str , int str_length , int scale , int x_loc , int y_loc )
    Remarks The scale runs from 1 to N but the characters get pretty big about 6.


    Table of Contents Function Index

    MSBIN2IE.ASM - MicroSoft basic BINary float format 2 IEEE format

    2 routines to convert a Microsoft 4 byte float to a IEEE 4 byte float and back. These are the Microsoft routines hacked out of the run-time library to support commodity data file reads from the Borland environment.


    Function fmsbintoieee
    Include file DTFL_ACC.H
    Prototype int fmsbintoieee( float *src4 , float *dest4 )
    Remarks Microsoft float to IEEE returns 0 - normal , 1 - overflow


    Function fieeetomsbin
    Include file DTFL_ACC.H
    Prototype int fieeetomsbin( float *src4 , float *dest4 )
    Remarks IEEE float to Microsoft returns 0 - normal , 1 - overflow


    Table of Contents Function Index

    LOWLEVEL.ASM

    Here are the low level assembler routines


    Function direct_disk_read
    Include file LOWLEVEL.H
    Prototype int direct_disk_read( char *buffer , int drive , int start_sector , int num_of_sectors )
    Remarks This routine performs a Int 25h disk read. Return 0 - Normal else the error code.


    Function direct_disk_write_2_floppy
    Include file LOWLEVEL.H
    Prototype int direct_disk_write_2_floppy( char *buffer , int floppy_drive , int start_sector )
    Remarks This routine performs a Int 26h disk write. Return 0 - Normal else the error code.


    Function move_ROM_date_2_str
    Include file LOWLEVEL.H
    Prototype void move_ROM_date_2_str( char *dest_str_address )
    Remarks Copy the BIOS ROM date str into user memory.


    Function get_kybd_status_bytes
    Include file LOWLEVEL.H
    Prototype int get_kybd_status_bytes( void )
    Remarks Fetch both of the keyboard status bytes.


    Function set_kybd_status_bytes
    Include file LOWLEVEL.H
    Prototype void set_kybd_status_bytes( int bytes )
    Remarks Update the keyboard status bytes. Use the return int from get_kybd_status_bytes(). Only the status flags in 0x0417 are updated. 0x0418 is not touched.


    Function get_kybd_scan_code
    Include file LOWLEVEL.H
    Prototype int get_kybd_scan_code( void )
    Remarks Wait till a key as available and return it. If key is an extended key return scan code + 256.


    Function div_2_kill_time
    Include file LOWLEVEL.H
    Prototype void div_2_kill_time( int dummy1 , int dummy2 )
    Remarks This a simple time wasting routine.


    Function get_system_time
    Include file LOWLEVEL.H
    Prototype long get_system_time( void )
    Remarks Get the current MSDOS 32 bit clock tick value.


    Function my_clear_memory
    Include file LOWLEVEL.H
    Prototype void my_clear_memory( char *start_address , int words_to_clear ) ;
    Remarks Clear a range of memory in words.


    Function submit_a_file
    Include file LOWLEVEL.H
    Prototype void submit_a_file( int *spooler_packet_address )
    Remarks Submit a file to the print deamon.


    Table of Contents Function Index

    VIDEO_IO.ASM

    A few video string display routines. The BIOS coordinate set runs from 0 , 0 to 24 , 79. If you prefer 1 , 1 to 25 , 80 then use the front-end macros defined in VIDEO_IO.H.


    Function bios_clear
    Include file VIDEO_IO.H
    Prototype void bios_clear( void )
    Remarks Clear the screen by resetting it and save the current page and mode for later use.


    Function bios_home_cursor
    Include file VIDEO_IO.H
    Prototype void bios_home_cursor( void )
    Remarks Use the video BIOS to home the cursor.


    Function bios_move
    Include file VIDEO_IO.H
    Prototype void bios_move( int row , int col )
    Remarks Use the video BIOS to move to row/column.


    Function bios_clear_rng
    Include file VIDEO_IO.H
    Prototype void bios_clear_rng( int top_line , int bot_line )
    Remarks Use the video BIOS to clear a range of lines.


    Function bios_scroll_area
    Include file VIDEO_IO.H
    Prototype void bios_scroll_area( int lines_to_scroll , int left_row , int left_col , int right_row , right_col )
    Remarks Front-end to the video BIOS scroll function, scrolls lines_to_scroll number of lines up in the window formed by the left and right corners.


    Function bios_scroll_lines
    Include file VIDEO_IO.H
    Prototype void bios_scroll_lines( int lines_to_scroll , int top_line , int bottom_line )
    Remarks Front-end to the video BIOS scroll function, scrolls lines_to_scroll number of lines up in the full line window formed by the top and bottom lines.


    Function bios_set_video_line_attributes
    Include file VIDEO_IO.H
    Prototype void bios_set_video_line_attributes( int row , int col , int len , int atr )
    Remarks Change the current video attributes for one line


    Function bios_vputs_at
    Include file VIDEO_IO.H
    Prototype void bios_vputs_at( int row , int col , char *str_ptr )
    Remarks Write at requested cursor position and don't advance the cursor.


    Function bios_vputs
    Include file VIDEO_IO.H
    Prototype void bios_vputs( char *str_ptr )
    Remarks Write at current cursor position and advance the cursor.


    Table of Contents Function Index

    LMACROS.INC

    Some macros to make assembler coding easy.

    macro declaration procdef macro pname,args ; ; Externally visible procedure with arguments definition

    macro declaration entrdef macro pname, args ; ; Externally visible entry point with arguments definition

    macro declaration internal macro pname

    ; Internal near procedure entry definition

    macro declaration intrdef macro pname ; ; Internal jump label definition

    macro declaration pret macro ; ; Procedure Return ; To be used on returning from externally visible procedures with/without ; Arguments or from internal procedures with no arguments ; Will restore bp if needed and any save_regs macro saved registers

    macro declaration pend macro pname ; ; Procedure end

    macro declaration ipend macro pname ; ; Internal procedure end

    macro declaration decll macro list ; ; This macro will process the argument list on a procedure call

    macro declaration decl macro aname, type ; This macro equates 'aname' to an argument on the stack and defines ; the referencing offset. This is the AZTEC version.

    macro declaration arg_offset macro sym_name , dt_size , cur_arg ; Since MASM (and TASM) don't expand a EQU symbol inside another ; EQU define we need to play games with another macro so we can force ; the expansion. This behavior appears to have been a "fix" that was added ; in MASM 5.0, the docs refer to prior versions doing an numeric expansion ; in text strings. If this is true MASM 4.? and lower should work fine with ; the Aztec version of this macro.

    macro declaration decl macro aname, type ; This macro equates 'aname' to an argument on the stack and defines ; the referencing offset. This is the MASM | TASM version and uses ; arg_offset to do its work.

    macro declaration ldptr macro dest, argname, seg ; ; This macro loads an arg pointer into DEST, with optional SEGment

    macro declaration retptrm macro src,seg ; ; Return a pointer

    macro declaration retptrr macro src,seg

    ; Return a data item

    macro declaration retnull macro

    ; Return NULL

    macro declaration pushds macro

    ; Save ds if long_ptr

    macro declaration popds macro

    ; Restore ds if long_ptr

    macro declaration finish macro

    ; Simple end codeseg

    macro declaration save_regs macro args

    ; Autosave registers in a procedure

    macro declaration save_a_reg macro a_reg ; ; Worker macro for save_regs, save one register and also error check ; for illegal saves and out of order register lists.

    macro declaration auto_restore_regs macro

    ; Autorestore registers while exiting a procedure

    macro declaration ASCIIZ macro var,raw_str

    ; Make a ASCIIZ string (C style - NULL terminated)

    macro declaration CLABEL macro var , size

    ; Generate a public C label for an assembler variable

    macro declaration CPUBLIC macro var , size , initial_value

    ; Allocate a public C variable


    Table of Contents Function Index

    CSTM_RPT.C

    A program to easily run multiple indicators and systems in parallel against a data set and then generate a custom report for the user.

    The basic program logic is that the user gives us a report template file and 1 (or more) data ticker strings. We first process the template file into process records. The template lines consist of file constant verbs or action verbs. The concept is that process records process data items into output values. Once the template file is parsed, each of the user requested data files are loaded in turn and run against the report template.


    Function main
    Include file CSTM_RPT.H
    Prototype void main( int argc , char **argv )
    Remarks Program entry point: expected command line input - CSTM_RPT report_template_file ticker_str [ ticker_str ... ]


    Function cntl_c_handler
    Include file CSTM_RPT.H
    Prototype void cntl_c_handler( void )
    Remarks Catch Cntl C so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function math_exception_handler
    Include file CSTM_RPT.H
    Prototype void math_exception_handler( int status_word , int error_type )
    Remarks Catch math errors so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function local_exit
    Include file CSTM_RPT.H
    Prototype void local_exit( int exit_code )
    Remarks Master program exit catcher. All fatal library errors will also come here.


    Function dspy_debug_hook_vars
    Include file CSTM_RPT.H
    Prototype void dspy_debug_hook_vars( int exit_code )
    Remarks Display program defined debug vars at image-rundown if debug_flag == TRUE.


    Function final_exit_cleanup
    Include file CSTM_RPT.H
    Prototype void final_exit_cleanup( int exit_code )
    Remarks Do final image-rundown cleanup here. Also force debug_flag to TRUE if exit_code != SS_NORMAL.


    Function chk_config_args
    Include file CSTM_RPT.H
    Prototype void chk_config_args( void )
    Remarks Do a check that necessary run-time stuff has been defined and that the user command line arguments make sense.


    Function chk_data_tables
    Include file CSTM_RPT.H
    Prototype void chk_data_tables( void )
    Remarks This is a run-time check that all the definition tables are the same size.


    Function process_template_file
    Include file CSTM_RPT.H
    Prototype void process_template_file( char *template_file )
    Remarks Load and process a report template file into the process_records.


    Function process_1_template_line
    Include file CSTM_RPT.H
    Prototype void process_1_template_line( char *input_line )
    Remarks Worker routine to process a single template line into a process_record.


    Function process_ticker_list_file
    Include file CSTM_RPT.H
    Prototype void process_ticker_list_file( char *ticker_file_name )
    Remarks Process a file of ticker_strs and run the defined report template against each of them.


    Function process_1_ticker
    Include file CSTM_RPT.H
    Prototype void process_1_ticker( char *ticker_str )
    Remarks Run the defined report for one ticker.


    Function init_global_vars
    Include file CSTM_RPT.H
    Prototype void init_global_vars( void )
    Remarks Initialize the program global and permanent variables.


    Function free_global_vars
    Include file CSTM_RPT.H
    Prototype void free_global_vars( void )
    Remarks A nice hook to free global vars. Not really needed in this application.


    Function init_process_vars
    Include file CSTM_RPT.H
    Prototype void init_process_vars( void )
    Remarks Called on each pass through process_1_ticker. Init all vars needed for defined report's process records and zero the output buckets.


    Function free_process_vars
    Include file CSTM_RPT.H
    Prototype void free_process_vars( void )
    Remarks Called at the end of each pass through process_1_ticker to free the ticker's DATA_RECs.


    Function validate_primary_verb
    Include file CSTM_RPT.H
    Prototype void validate_primary_verb( void )
    Remarks Validate that the first token is a primary verb (or an abbreviation of one). Will set the GLOBAL var verb_idx to either the matched verb or max table size if not found.


    Function chk_if_valid_data_source
    Include file CSTM_RPT.H
    Prototype int chk_if_valid_data_source( int found_data_src )
    Remarks Check if found data source is valid for this primary verb.


    Function find_data_source
    Include file CSTM_RPT.H
    Prototype int find_data_source( char *request )
    Remarks Identify if the user request is a valid data source (or an abbreviation of one). Also remaps the file constant data source to their special flag numbers.


    Function rpt_current_state
    Include file CSTM_RPT.H
    Prototype void rpt_current_state( void )
    Remarks Do a run-time dump of the current state of all user visible indicator variables.


    Function process_paren_assignment
    Include file CSTM_RPT.H
    Prototype void process_paren_assignment( int idx )
    Remarks Called when a set of parentheses is found in a token str (tokens[ idx ]). This code identifies which trading system the user is providing overbought and oversold thresholds for, and then stores them. Example - threshold_trd_sig( 2000 , -2000 )


    Table of Contents Function Index

    CSTM2RPT.C

    A program to easily run multiple indicators and systems in parallel against a data set and then generate a custom report for the user.


    Function set_token_ptrs
    Include file CSTM2RPT.H
    Prototype void set_token_ptrs( char *input_line )
    Remarks This is the first major routine used to parse the user's template line into something meaningful. This routine will init all line parse vars and tokens[] array. It will then break the input_line into white-space delimited NULL terminated token strings (this means input_line is changed). At exit the the array token_cnt is set and the tokens[].str sections look like a AWK $1 , $2 .. $N token array (this means tokens[ 0 ].str contains the first token on the line, etc.).


    Function set_token_flags
    Include file CSTM2RPT.H
    Prototype void set_token_flags( void )
    Remarks Now that the tokens[] array is built, we'll try is see if we can recognize any of the tokens as special flag verbs. If we do - hit the appropriate special flag and mark the token as used.


    Function special_token_saves
    Include file CSTM2RPT.H
    Prototype void special_token_saves( void )
    Remarks Now handle the parentheses and equal sign assignments (and mark as used). Also update the cur_prc_rec->spec_output_flag if necessary.


    Function get_first_int_arg
    Include file CSTM2RPT.H
    Prototype int get_first_int_arg( void )
    Remarks Return the first token string after the primary verb that begins with a digit and don't worry if it has been used yet. Return 0 if none found.


    Function get_first_unused_int_arg
    Include file CSTM2RPT.H
    Prototype int get_first_unused_int_arg( void )
    Remarks Return the first token string after the primary verb that begins with a digit and this time check that it hasn't been used yet. Mark it as now having been used. Return 0 if none found.


    Function get_first_unused_arg
    Include file CSTM2RPT.H
    Prototype char *get_first_unused_arg( void )
    Remarks Get the first unused argument of any type. If we are parsing a math operation then we start with the first token str else we skip the primary verb token and begin searching at the next token. Return NULL if none found.


    Function get_first_unused_arg_n_mark_used
    Include file CSTM2RPT.H
    Prototype char *get_first_unused_arg_n_mark_used( void )
    Remarks Get the first unused argument of any type. If we are parsing a math operation then we start with the first token str else we skip the primary verb token and begin searching at the next token. This time mark the found one as used. Return NULL if none found.


    Function get_label_str
    Include file CSTM2RPT.H
    Prototype char *get_label_str( void )
    Remarks Try a number of sources to generate a label str for the cur_prc_rec. First check if the user gave us one, if so, return a clone of it. Then check if the cur_prc_rec is something other than a file constant. If it is and the cur_prc_rec->spec_proc_flag does not have the NO_SIZE bit set then build a label str consisting df_label[ verb_idx] plus the size value the user gave us. Else just return the df_label[ verb_idx ].


    Function get_unused_label_str
    Include file CSTM2RPT.H
    Prototype char *get_unused_label_str( void )
    Remarks Scan the tokens and return the first unused label_str (and mark it as used) or return NULL.


    Function get_label_str_secondary
    Include file CSTM2RPT.H
    Prototype char *get_label_str_secondary( int src_idx , int size )
    Remarks Return a copy of the secondary data source's label str. If size != 0 append it to the label str too.


    Function make_secondary_label_str
    Include file CSTM2RPT.H
    Prototype void make_secondary_label_str( char *buffer , char *df_msg )
    Remarks Check if we have an available user supplied label str and either copy it (if found) else the df_msg into the caller's buffer.


    Function set_data_source_n_labels
    Include file CSTM2RPT.H
    Prototype void set_data_source_n_labels( int size )
    Remarks Set the data_source and label_str for the cur_prc_rec. Also hook the label_str to the right slot in the ref_strs[ output_cnt ].


    Function chk_4_label_update_with_defaults
    Include file CSTM2RPT.H
    Prototype void chk_4_label_update_with_defaults( int size , char *use_this_label )
    Remarks If the user didn't give us a size on an indicator that has defaults, we need to update the label_str with the indicator's default size. Also hook the label_str to the right slot in the ref_strs[ output_cnt ].


    Function bld_ind_label_str
    Include file CSTM2RPT.H
    Prototype void bld_ind_label_str( char *base_str , int df_length )
    Remarks Build a indicator label str and hook it up to the ref_strs[ output_cnt ] array.


    Function get_format_str
    Include file CSTM2RPT.H
    Prototype char *get_format_str( void )
    Remarks Return either the user provided format str else the df_formats[ verb_idx ].


    Function report_unused_tokens
    Include file CSTM2RPT.H
    Prototype void report_unused_tokens( void )
    Remarks OK everything is parsed, check if we've got anything marked as still unused. If so, tell the user.


    Function set_output_formats
    Include file CSTM2RPT.H
    Prototype void set_output_formats( void )
    Remarks Set the default price data output format str (depending on output_places).


    Function clone_cur_prc_rec
    Include file CSTM2RPT.H
    Prototype void clone_cur_prc_rec( char *label_str , int no_out_flag , int no_tsig_flag )
    Remarks Clone a copy of the cur_prc_rec, update the ref_strs[ output_cnt ] array. At exit the cur_prc_rec will point to the new PRC_REC.


    Function inc_cur_prc_rec
    Include file CSTM2RPT.H
    Prototype void inc_cur_prc_rec( void )
    Remarks Since prc_master->prc_rec[] is an array of ptrs a simple cur_prc_rec++ won't work.


    Function dec_cur_prc_rec
    Include file CSTM2RPT.H
    Prototype void dec_cur_prc_rec( void )
    Remarks ditto


    Function dump_ticker_str
    Include file CSTM2RPT.H
    Prototype void dump_ticker_str( char *ticker )
    Remarks Dump the ticker str to the report and to the user so he sees that something is happening.


    Function rpt_template_error
    Include file CSTM2RPT.H
    Prototype void rpt_template_error( char *msg )
    Remarks Report that a error occured in parsing a template line.


    Function ln_to_upper_except_in_dquotes
    Include file CSTM2RPT.H
    Prototype void ln_to_upper_except_in_dquotes( char *str )
    Remarks Convert all lower case characters in a str to upper case except the characters in between double quotes. exp - this is a "test" becomes THIS IS A "test"


    Function eat_commas_except_in_dquotes
    Include file CSTM2RPT.H
    Prototype void eat_commas_except_in_dquotes( char *str )
    Remarks Change all commas found in a str to spaces except the ones inside of double quotes.


    Function eat_white_space_in_str
    Include file CSTM2RPT.H
    Prototype void eat_white_space_in_str( char *src , char *dest ) // do the tighten-up
    Remarks Delete all white_space from a str.


    Function is_this_a_number_str
    Include file CSTM2RPT.H
    Prototype int is_this_a_number_str( char *target )
    Remarks Return TRUE is the target str is a number else FALSE.


    Function strncpy_n_blank_pad
    Include file CSTM2RPT.H
    Prototype void strncpy_n_blank_pad( char *dest , char *src , int len )
    Remarks Do a strncpy then space pad to the caller's request length.


    Function rpt_memory_left_if_debug_flag
    Include file CSTM2RPT.H
    Prototype void rpt_memory_left_if_debug_flag( void )
    Remarks If the debug_flag == TRUE then report currently available near memory.


    Function dump_prc_master_if_debug_flag
    Include file CSTM2RPT.H
    Prototype void dump_prc_master_if_debug_flag( void )
    Remarks If the debug_flag == TRUE then dump all the allocated process_records.


    Function output_cur_prc_rec
    Include file CSTM2RPT.H
    Prototype void output_cur_prc_rec( void )
    Remarks Dump a debug look at the process_record pointed at by cur_prc_rec.


    Function dump_ref_str_if_debug_flag
    Include file CSTM2RPT.H
    Prototype void dump_ref_str_if_debug_flag( void )
    Remarks If debug_flag == TRUE dump the whole ref_strs[] array.


    Function clear_the_prc_array
    Include file CSTM2RPT.H
    Prototype void clear_the_prc_array( void )
    Remarks Init all the process_records in the prc_master struct and call their individual init_routines (if they have one).


    Function chk_4_post_proc_requests
    Include file CSTM2RPT.H
    Prototype void chk_4_post_proc_requests( void )
    Remarks Check for any post DATA_REC processing special requests.


    Function save_trade_signal_value
    Include file CSTM2RPT.H
    Prototype void save_trade_signal_value( int idx , int store_value )
    Remarks Update the out_ptr->signal_state[ idx ] with the requested new store_value and handle forward_time processing.


    Function save_output_value
    Include file CSTM2RPT.H
    Prototype void save_output_value( float store_value )
    Remarks Update the out_ptr->data[ cur_prc_rec->output_idx ] with the requested new store_value. Also handle user log requests and forward_time processing.


    Function output_str_2_log_file
    Include file CSTM2RPT.H
    Prototype void output_str_2_log_file( char *str )
    Remarks Hook to here to allow support for user requested last N records.


    Function get_data_value
    Include file CSTM2RPT.H
    Prototype float get_data_value( void )
    Remarks Fetch the current value for the defined data_source for the cur_prc_rec. This could be either a file constant or a previously calculated process record. The GLOBAL var last_data_value is also set.


    Function general_data_store
    Include file CSTM2RPT.H
    Prototype void general_data_store( void )
    Remarks A generalized data store for all the file constants.


    Function cnvt_tbond_vars_if_necessary
    Include file CSTM2RPT.H
    Prototype void cnvt_tbond_vars_if_necessary( void )
    Remarks If bond_decimal == TRUE, find all process_records with their PRICE_DATA bit set in spec_proc_flag and convert their output values back to T-Bond 1/32s format.


    Function init_out_array
    Include file CSTM2RPT.H
    Prototype void init_out_array( void )
    Remarks Init out_array to a double linked circular queue.


    Function clear_the_out_array
    Include file CSTM2RPT.H
    Prototype void clear_the_out_array( void )
    Remarks Clear all the out_ptr's data and signal_state buckets for all the process records.


    Function output_the_out_array
    Include file CSTM2RPT.H
    Prototype void output_the_out_array( void )
    Remarks OK the processing is all done so dump the out_array to output_device and give the user his report.


    Function compare_dates
    Include file CSTM2RPT.H
    Prototype static int compare_dates( float date1 , float date2 )
    Remarks A simple compare function that returns values like strcmp, 0 = match, -1 = date1 < date2 and 1 = date1 > date2.


    Function find_rec_by_date
    Include file CSTM2RPT.H
    Prototype int find_rec_by_date( float target_date )
    Remarks Given a already open data file, search forward with retrys for a target date. Calls find_rec_by_date2 for each attempt.


    Function find_rec_by_date2
    Include file CSTM2RPT.H
    Prototype static int find_rec_by_date2( float target_date )
    Remarks This routine will search a file for a target_date.


    Function test_find_rec_by_date
    Include file CSTM2RPT.H
    Prototype int test_find_rec_by_date( void )
    Remarks


    Function clone_2_far_n_free
    Include file CSTM2RPT.H
    Prototype DATA_REC far *clone_2_far_n_free( DATA_REC *src )
    Remarks Clone a near memory loaded DATA_REC array to far memory and free up the near heap memory.


    Function load_secondary_data
    Include file CSTM2RPT.H
    Prototype void load_secondary_data( void )
    Remarks Load any user requested secondary data files into far memory DATA_REC arrays for the whole program run.


    Function init_secondary_data_ptrs
    Include file CSTM2RPT.H
    Prototype void init_secondary_data_ptrs( void )
    Remarks Set the cur_sd?_rec and last_sd?_rec ptrs to the beginning of the secondary data DATA_REC arrays.


    Function increment_secondary_data_ptrs
    Include file CSTM2RPT.H
    Prototype void increment_secondary_data_ptrs( void )
    Remarks Advanced the secondary data DATA_REC array ptrs.


    Function init_forward_data
    Include file CSTM2RPT.H
    Prototype void init_forward_data( void )
    Remarks Simulate new data by setting the current data record ptrs back with their last_dt_rec ptrs.


    Function set_ptrs_2_next_day
    Include file CSTM2RPT.H
    Prototype void set_ptrs_2_next_day( void )
    Remarks Calculate the next trading forward into time and update the DATA_REC current data record ptr dates.


    Function set_file_rec_numbers
    Include file CSTM2RPT.H
    Prototype void set_file_rec_numbers( void )
    Remarks Calculate where to start reading the file based on num_of_days_to_output, days_needed and maybe start_date & last_date info. Will set num_of_recs_2_read.


    Function load_the_data_array
    Include file CSTM2RPT.H
    Prototype DATA_REC *load_the_data_array( char *ticker )
    Remarks Allocate, load and return a near memory DATA_REC array with num_of_recs_2_read data records.


    Function cnvt_bond_data_into_decimal
    Include file CSTM2RPT.H
    Prototype void cnvt_bond_data_into_decimal( void )
    Remarks Convert the open,high,low and close fields of the main DATA_REC array from T-Bond 1/32's into T-Bond decimal if necessary.


    Function process_the_data_array
    Include file CSTM2RPT.H
    Prototype void process_the_data_array( void )
    Remarks Run the process_records against the data arrays.


    Function calc_next_trading_date
    Include file CSTM2RPT.H
    Prototype float calc_next_trading_date( float last_rec_date )
    Remarks Convert a given date to the next market day.


    Function roll_2_tomorrow
    Include file CSTM2RPT.H
    Prototype UINT roll_2_tomorrow( UINT last_rec_julian )
    Remarks A simple (and stupid) advance to the next market day, holiday checking is not done.


    Table of Contents Function Index

    CSTM3RPT.C

    A program to easily run multiple indicators and systems in parallel


    Function get_trade_signal
    Include file CSTM3RPT.H
    Prototype char *get_trade_signal( int signal )
    Remarks Use the signal value to index into an array of char strs of trade signals and market state messages.


    Function set_trade_signal_state
    Include file CSTM3RPT.H
    Prototype void set_trade_signal_state( int idx , int opinion )
    Remarks Set and update the trade signal state for output number - idx according to the opinion.


    Function update_trade_signal_state
    Include file CSTM3RPT.H
    Prototype void update_trade_signal_state( int idx )
    Remarks Update the current trade signal for state changes (exp. old state GO_LONG, new state at exit - LONG).


    Function set_ind_signal_state
    Include file CSTM3RPT.H
    Prototype void set_ind_signal_state( int idx , float cur_value , float last_value )
    Remarks Calculate an indicator trade signal state using as a basis the current and last indicator values.


    Function calc_ob_os_signal_state
    Include file CSTM3RPT.H
    Prototype void calc_ob_os_signal_state( int idx , float overbought_threshold , float oversold_threshold )
    Remarks Calculate an indicator trade signal state by evaluating the current indicator value in relation to overbought and oversold thresholds.


    Function calc_rev_ob_os_signal_state
    Include file CSTM3RPT.H
    Prototype void calc_rev_ob_os_signal_state( int idx , float overbought_threshold , float oversold_threshold )
    Remarks This is the same as the last routine except this one has reversed threshold logic to handle flakey thresholds like original Williams' %R.


    Function set_ob_os_ind_signal_state
    Include file CSTM3RPT.H
    Prototype void set_ob_os_ind_signal_state( int idx , int opinion )
    Remarks Set and update the indicator trade signal state using as a basis the indicator value in relation to overbought and oversold thresholds.


    Function allocate_trd_signal_routine
    Include file CSTM3RPT.H
    Prototype void allocate_trd_signal_routine( void )
    Remarks Allocate and initialize a user requested trade signal process routine structure and hook it on to the cur_prc_rec.


    Function chk_4_user_requested_trd_sig
    Include file CSTM3RPT.H
    Prototype int chk_4_user_requested_trd_sig( float cur_ind , float src_data )
    Remarks Check the cur_prc_rec's trd_sig_ptr, if a user requested special trade signal routine is found, run it.


    Function fe_calc_ob_os_signal_state
    Include file CSTM3RPT.H
    Prototype void fe_calc_ob_os_signal_state( void )
    Remarks Front end calc_ob_os_signal_state() since function ptrs don't have prototypes the float arguments get pushed as ints


    Function fe_set_ind_signal_state
    Include file CSTM3RPT.H
    Prototype void fe_set_ind_signal_state( void )
    Remarks Front end set_ind_signal_state() since function ptrs don't have prototypes the float arguments get pushed as ints


    Function validate_with_str_array_stricmp
    Include file CSTM3RPT.H
    Prototype int validate_with_str_array_stricmp( char *validate_strs[] , char *target , int cnt )
    Remarks Normal validate_with_str_array except use stricmp for a case-insensitive compare between target and validate_strs.


    Table of Contents Function Index

    SNAPSHOT.C -

    A Q & D program to load 1 to 4 charts and (and possible indicators) maybe then call the resident EPSON driver for a snapshot suitable for printing with G_RPT.

    TDF_Lib buyers - sorry but this program release is meant only as a demo program of the graphics subsystem so I have AWK-ed out EPSON printer stuff and some proprietary indicators.


    Function main
    Include file SNAPSHOT.H
    Prototype void main( int argc , char *argv[] )
    Remarks Program entry point: expected command line input - SNAPSHOT ticker_str [ ticker_str ... ]


    Function local_exit
    Include file SNAPSHOT.H
    Prototype void local_exit( int exit_code )
    Remarks Master program exit catcher. All fatal library errors will also come here.


    Function final_exit_cleanup
    Include file SNAPSHOT.H
    Prototype void final_exit_cleanup( int exit_code )
    Remarks Do final image-rundown cleanup here. Also force debug_flag to TRUE if exit_code != SS_NORMAL.


    Function cntl_c_handler
    Include file SNAPSHOT.H
    Prototype void cntl_c_handler( void )
    Remarks Catch Cntl C so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function math_exception_handler
    Include file SNAPSHOT.H
    Prototype void math_exception_handler( int status_word , int error_type )
    Remarks Catch math errors so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function dspy_debug_hook_vars
    Include file SNAPSHOT.H
    Prototype void dspy_debug_hook_vars( int exit_code )
    Remarks Display program defined debug vars at image-rundown if debug_flag == TRUE.


    Function output_a_timestamp_msg
    Include file SNAPSHOT.H
    Prototype void output_a_timestamp_msg( char *msg )
    Remarks Output a message with a time stamp to the tube.


    Function cnvt_cmd_ln_args
    Include file SNAPSHOT.H
    Prototype void cnvt_cmd_ln_args( void )
    Remarks Convert, validate or store command switches here.


    Function allocate_data_structures
    Include file SNAPSHOT.H
    Prototype void allocate_data_structures( void )
    Remarks Allocate the program GLOBAL variables.


    Function free_data_structures
    Include file SNAPSHOT.H
    Prototype void free_data_structures( void )
    Remarks Deallocate the program GLOBAL variables.


    Function calc_cycle_position
    Include file SNAPSHOT.H
    Prototype float calc_cycle_position( int cycle_length , int cur_offset )
    Remarks Calculate the current position in a cycle, return x where 1 >= x >= -1 with 1 = top of the cycle & -1 = bottom of the cycle.


    Function auto_select_a_scr
    Include file SNAPSHOT.H
    Prototype void auto_select_a_scr()
    Remarks Draw a specific pre-programmed chart by command line request. Only case 1 currently defined in this demo ( 1 is setup to chart a passed-in ASCII file from a CSTM_RPT log). In my version of this program I use about 10 pre-defined screens which are selected at call time by the calling program for different overlays. You would use this version like this - given a # IND_EXP.TPL - CSTM_RPT export demo template file date # the date will log automatically high log # will output as the second field on each line low log # etc. close log vol log rsi 14 log # this will be exported in the 6th field - open ema 3 rsi_14 log # and this in the open interest field # end IND_EXP.TPL then run CSTM_RPT and request logging of the last 50 records CSTM_RPT IND_EXP.TPL DOW /L50 /onul this will then produce an ASCII file named CSTM_RPT.LOG containing the exported data which can instantly displayed by using - SNAPSHOT /A /s1 CSTM_RPT /A means ASCII file, /s1 - auto_select scr # 1, and CSTM_RPT means that the ASCII ticker to load is CSTM_RPT.


    Function support_chart_movement
    Include file SNAPSHOT.H
    Prototype void support_chart_movement( void )
    Remarks Support movement between the series of charts for DEMO #3 - 1 ticker calls.


    Table of Contents Function Index

    DUMP_CDT.C - Dump Commodity data

    A Q & D to dump CSI & Computrac master and data files to stdout to see what I've got.


    Function main
    Include file DUMP_CDT.H
    Prototype void main( int argc , char **argv )
    Remarks Program entry point: expected command line input examples - DUMP_CDT // dump master file in current directory DUMP_CDT a_directory_path // dump master file in given directory DUMP_CDT a_ticker_str // dump ticker data file in the current dir DUMP_CDT dir_path ticker_str // dump ticker data file in given dir


    Function cntl_c_handler
    Include file DUMP_CDT.H
    Prototype void cntl_c_handler( void )
    Remarks Catch Cntl C so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function math_exception_handler
    Include file DUMP_CDT.H
    Prototype void math_exception_handler( int status_word , int error_type )
    Remarks Catch math errors so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function local_exit
    Include file DUMP_CDT.H
    Prototype void local_exit( int exit_code )
    Remarks Master program exit catcher. All fatal library errors will also come here.


    Function set_cmd_line_flags
    Include file DUMP_CDT.H
    Prototype void set_cmd_line_flags( void )
    Remarks Do a sanity test on the user inputed cmd line args.


    Function set_f_scaler
    Include file DUMP_CDT.H
    Prototype void set_f_scaler( void )
    Remarks Convert the user scale factor into a float multiplier to use.


    Function set_database_flags
    Include file DUMP_CDT.H
    Prototype void set_database_flags( void )
    Remarks Check the current directory and see what kind of master files we find.


    Function dump_the_master_file
    Include file DUMP_CDT.H
    Prototype void dump_the_master_file( char *ticker )
    Remarks Called here with a unfindable ticker string "TDF_LTD!" and with the GLOBAL var log_master_2_output_device set to TRUE so the standard library look-up routine lookup_data_file_num( ticker ) will dump all entries in the master file.


    Function process_one_data_file
    Include file DUMP_CDT.H
    Prototype void process_one_data_file( char *ticker_str )
    Remarks Read, process (bond conversion &| weekly/monthly compression &| scaling) and output the requested data file.


    Function dump_the_data_file_header
    Include file DUMP_CDT.H
    Prototype void dump_the_data_file_header( char *ticker )
    Remarks Dump the CSI or Computrac data file header information, then the output banner line to the output_device in preparation for dumping the data file's data.


    Function dump_cpt_data_file_header
    Include file DUMP_CDT.H
    Prototype void dump_cpt_data_file_header( char *ticker )
    Remarks Dump the Computrac/Metastock data file header information.


    Function dump_csi_data_file_header
    Include file DUMP_CDT.H
    Prototype void dump_csi_data_file_header( char *ticker )
    Remarks Dump the CSI data file header information.


    Function print_data_struct_compact
    Include file DUMP_CDT.H
    Prototype void print_data_struct_compact( DATA_REC *data_ptr )
    Remarks Dump a DATA_REC out to a single line on the output_device.


    Function scale_data_rec
    Include file DUMP_CDT.H
    Prototype void scale_data_rec( DATA_REC *data_ptr )
    Remarks Scale all the price fields in the caller's DATA_REC by muliplying them by the user f_scaler value.


    Function init_compress_data_struct
    Include file DUMP_CDT.H
    Prototype void init_compress_data_struct( DATA_REC *data_ptr )
    Remarks Initialize all the fields in the DATA_REC that we use for compression caching.


    Function add_2_compress_data_struct
    Include file DUMP_CDT.H
    Prototype void add_2_compress_data_struct( DATA_REC *cmp_data_ptr , DATA_REC *cur_rec_ptr )
    Remarks Update the compression structure with the current DATA_REC.


    Function calc_mth_idx
    Include file DUMP_CDT.H
    Prototype int calc_mth_idx( float date )
    Remarks Strip the month from a YYMMDD float date and return it as a int.


    Function calc_day_of_week_index
    Include file DUMP_CDT.H
    Prototype int calc_day_of_week_index( float date )
    Remarks Get a day of the week index from a YYMMDD float date.


    Function compress_day_to_week_or_month
    Include file DUMP_CDT.H
    Prototype void compress_day_to_week_or_month( DATA_REC *cmp_data_ptr , DATA_REC *cur_rec_ptr )
    Remarks Compress the daily data into the user requested size and hit the compress_flush flag when needed.


    Function chk_if_1st_arg_is_a_db_path
    Include file DUMP_CDT.H
    Prototype int chk_if_1st_arg_is_a_db_path( int argc , char *argv[] )
    Remarks Check if the first user command line argument is a database path string. If it is, clone it to the GLOBAL var data_path.


    Table of Contents Function Index

    ANAL_CYC.C - ANALyze CYCle

    A Q & D program to read a file of ASCII cycles and track where a market is in relation to them. Another goal is to track what Jeff Bower at FNN humbly calls Bower power shifts (cycle confluences). And now cross-ref the market high/low extremes and Fibonacci time projections from a FIB_RPT report in too.


    Function main
    Include file ANAL_CYC.H
    Prototype void main( int argc , char *argv[] )
    Remarks Program entry point: expected command line input - ANAL_CYC cycle_definition_file


    Function local_exit
    Include file ANAL_CYC.H
    Prototype void local_exit( int exit_code )
    Remarks Master program exit catcher. All fatal library errors will also come here.


    Function final_exit_cleanup
    Include file ANAL_CYC.H
    Prototype void final_exit_cleanup( int exit_code )
    Remarks Do final image-rundown cleanup here. Also force debug_flag to TRUE if exit_code != SS_NORMAL.


    Function cntl_c_handler
    Include file ANAL_CYC.H
    Prototype void cntl_c_handler( void )
    Remarks Catch Cntl C so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function output_a_timestamp_msg
    Include file ANAL_CYC.H
    Prototype void output_a_timestamp_msg( char *msg )
    Remarks Output a message with a time stamp to the tube.


    Function allocate_data_structures
    Include file ANAL_CYC.H
    Prototype void allocate_data_structures( void )
    Remarks Allocate the program GLOBAL variables.


    Function free_data_structures
    Include file ANAL_CYC.H
    Prototype void free_data_structures( void )
    Remarks Deallocate the program GLOBAL variables.


    Function load_cycle_data_file
    Include file ANAL_CYC.H
    Prototype void load_cycle_data_file( char *cycle_file )
    Remarks Load and process the cycle definition data file.


    Function process_cycle_data_rec
    Include file ANAL_CYC.H
    Prototype void process_cycle_data_rec( char *data_line )
    Remarks Called by ld_ascii_data_file to process each line of the user's cycle definition file. This routine will dispatch to the individual verb process routines.


    Function process_ticker_dt_rec
    Include file ANAL_CYC.H
    Prototype void process_ticker_dt_rec( char *ticker_line )
    Remarks Process a ticker string data record from the cycle definition file. The ticker_line will look like - "ticker dow".


    Function process_cycle_dt_rec
    Include file ANAL_CYC.H
    Prototype void process_cycle_dt_rec( char *cycle_line )
    Remarks Process a cycle definition data record from the cycle definition file. The cycle_line will look like - "cycle 01/03/95 25 bottom".


    Function save_cycle_rec
    Include file ANAL_CYC.H
    Prototype void save_cycle_rec( float base_date , int length , int node_type )
    Remarks Allocate and initialize a CREC to track this individual cycle.


    Function process_blend_dt_rec
    Include file ANAL_CYC.H
    Prototype void process_blend_dt_rec( char *blend_line )
    Remarks Process a blend cycle definition data record from the cycle definition file. A blend is the mathematical combination of 2 or more cycles yielding a sigmoidal curve. A blend_line will look like - "blend 10 20 30".


    Function calc_days_needed
    Include file ANAL_CYC.H
    Prototype void calc_days_needed( void )
    Remarks Calculate the number of bars of market data we need. The controlling variables are the longest cycle and oldest anchor_date.


    Function calc_all_cycle_positions
    Include file ANAL_CYC.H
    Prototype void calc_all_cycle_positions( void )
    Remarks Calculate all of the cycle positions for all the programmed cycle definitions.


    Function calc_one_cycle_position
    Include file ANAL_CYC.H
    Prototype void calc_one_cycle_position( CREC *cycle_rec )
    Remarks Calculate all the cycle positions for a single CREC cycle_rec.


    Function find_date_offset
    Include file ANAL_CYC.H
    Prototype static int find_date_offset( float target )
    Remarks Find the target_date in the dates[] array. Return either it's index or -1 as not found.


    Function calc_blended_cycles
    Include file ANAL_CYC.H
    Prototype void calc_blended_cycles( int blend_idx , int cycle_idx )
    Remarks Process cycle blend number - blend_idx against the current cycle positions found at cycle_idx.


    Function output_pending_cycles
    Include file ANAL_CYC.H
    Prototype void output_pending_cycles( void )
    Remarks Output the cycle position report.


    Function output_blend_structs
    Include file ANAL_CYC.H
    Prototype void output_blend_structs( void )
    Remarks Output to the report a description of all cycle blends that were programmed.


    Function output_one_blend_struct
    Include file ANAL_CYC.H
    Prototype static void output_one_blend_struct( int blend_idx )
    Remarks Output a single cycle blend description.


    Function output_data_4_metastock
    Include file ANAL_CYC.H
    Prototype void output_data_4_metastock( void )
    Remarks This is a hack to dump some data for importation into Metastock. I have left this in to show how to do it.


    Function do_fibonacci_crossref
    Include file ANAL_CYC.H
    Prototype void do_fibonacci_crossref( void )
    Remarks Load the data to cross-reference the Fibonacci time projections and the high / low market extremes generated by FIB_RPT to the cycle positions. What we need to do is read the ASCII text report generated by FIB_RPT, watch for various keywords in the report and process their data when found. Needless to say this code will only work if you buy FIB_RPT (or at-least it's demo). I left this code in also as an example (not a sales pitch). This code is controlled by the /F command line switch so ANAL_CYC will run fine without FIB_RPT.


    Function process_fib_rpt_line
    Include file ANAL_CYC.H
    Prototype void process_fib_rpt_line( char *data_line )
    Remarks Called by ld_ascii_data_file to process an individual report line from a FIB_RPT run.


    Function store_a_fib_projection
    Include file ANAL_CYC.H
    Prototype void store_a_fib_projection( int type , float date )
    Remarks Store a Fibonacci time projection.


    Function store_a_fib_node
    Include file ANAL_CYC.H
    Prototype void store_a_fib_node( int type , float date )
    Remarks Mark a day as a short-term market high/low node.


    Function blank_pad_2_length
    Include file ANAL_CYC.H
    Prototype void blank_pad_2_length( char *str , int length )
    Remarks Pad the caller's string to the request length with spaces.


    Table of Contents Function Index

    .C - NICE SHELl is empty startup shell for cloning, starting here

    A Q & D program to ?????????


    Function main
    Include file NICESHEL.H
    Prototype void main( int argc , char *argv[] )
    Remarks Program entry point: expected command line input - NICESHEL ??????????


    Function local_exit
    Include file NICESHEL.H
    Prototype void local_exit( int exit_code )
    Remarks Master program exit catcher. All fatal library errors will also come here.


    Function final_exit_cleanup
    Include file NICESHEL.H
    Prototype void final_exit_cleanup( int exit_code )
    Remarks Do final image-rundown cleanup here. Also force debug_flag to TRUE if exit_code != SS_NORMAL.


    Function cntl_c_handler
    Include file NICESHEL.H
    Prototype void cntl_c_handler( void )
    Remarks Catch Cntl C so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function output_a_timestamp_msg
    Include file NICESHEL.H
    Prototype void output_a_timestamp_msg( char *msg )
    Remarks Output a message with a time stamp to the tube.


    Function cnvt_cmd_ln_args
    Include file NICESHEL.H
    Prototype void cnvt_cmd_ln_args( void )
    Remarks Convert, validate or store command switches here.


    Function allocate_data_structures
    Include file NICESHEL.H
    Prototype void allocate_data_structures( void )
    Remarks Allocate the program GLOBAL variables.


    Function free_data_structures
    Include file NICESHEL.H
    Prototype void free_data_structures( void )
    Remarks Deallocate the program GLOBAL variables.


    Function load_cycle_data_file
    Include file NICESHEL.H
    Prototype void load_cycle_data_file( char *cycle_file )
    Remarks Load and process the cycle definition data file.


    Function process_cycle_data_rec
    Include file NICESHEL.H
    Prototype void process_cycle_data_rec( char *data_line )
    Remarks Called by ld_ascii_data_file to process each line of the user's cycle definition file. This routine will dispatch to the individual verb process routines.


    Table of Contents Function Index

    PPRINT.CPP - Pretty PRINTer

    A Q & D program to use the PRINTER and SPOOLER objects to Pretty Print C source.


    Function main
    Include file PPRINT.CPH
    Prototype void main( int argc , char *argv[] )
    Remarks Program entry point: expected command line input - PPRINT file_name [ file_name ... ] If PPRINT is linked with the WILDARGS.OBJ it will then support wildcard expansion in the file names provided on the command line.


    Function local_exit
    Include file PPRINT.CPH
    Prototype void local_exit( int exit_code )
    Remarks Master program exit catcher. All fatal library errors will also come here.


    Function final_exit_cleanup
    Include file PPRINT.CPH
    Prototype void final_exit_cleanup( int exit_code )
    Remarks Do final image-rundown cleanup here.


    Function cntl_c_handler
    Include file PPRINT.CPH
    Prototype void cntl_c_handler( int error_code )
    Remarks Catch Cntl C so we can exit via exit() and get a full file flush and close on any open files as well as any local rundown.


    Function report_fatal_error
    Include file PPRINT.CPH
    Prototype void report_fatal_error( char *msg )
    Remarks Dump the user's error message to stderr and exit.


    Table of Contents Function Index

    PRINTER.CPP - the method definitions for the Printer object


    Function Printer::Printer
    Include file PRINTER.CPH
    Prototype Printer::Printer( int t , enum margins m , enum page_size p )
    Remarks Printer - the constructor that initializes a printer. INP : int t - the size of the tabstops enum margins m - the type of margins to use enum page_size p - the type of page to use NOTE : if the file can't be opened, then out_dev is set to NULL to force subsquent operations to fail


    Function Printer::~Printer
    Include file PRINTER.CPH
    Prototype Printer::~Printer()
    Remarks ~Printer - cleanup before destroying the virtual printer // NOTE : Only generates output if something was printed NOTE : Output goes to the printer only when object is destroyed, ( i.e. , report is completed ) NOTE : This routine is now smart enough to use the PRINT deamon if available


    Function Printer::SetHeading
    Include file PRINTER.CPH
    Prototype void Printer::SetHeading( int head , char *text )
    Remarks SetHeading - Set/Remove a heading INP : int head - the heading number (from 1 to MAX_HDRS) char *text - the text str for the heading


    Function Printer::ClearHeadings
    Include file PRINTER.CPH
    Prototype void Printer::ClearHeadings()
    Remarks Set all the headings to NULL.


    Function Printer::Print
    Include file PRINTER.CPH
    Prototype void Printer::Print( char *s )
    Remarks Print a line to the printer. INP : char *s - the string to print NOTE : if we run out of room on the page, Print() will ejects the page and print new page headings.


    Function Printer::PrintHeading
    Include file PRINTER.CPH
    Prototype void Printer::PrintHeading()
    Remarks Print a page heading.


    Function Printer::intPrint
    Include file PRINTER.CPH
    Prototype void Printer::intPrint( char *s )
    Remarks intPrint - the internal line printing function INP : char *s - the string to print NOTE : There are four characters that invoke special processing : '\001' - the multispace character: used for justifying '\014' - the form feed '\n' - the newline: used to process the end of line '\t' - the normal tab character


    Table of Contents Function Index

    SPOOLER.CPP - definition of the printer spooler control object


    Function Spooler::Spooler
    Include file SPOOLER.CPH
    Prototype Spooler::Spooler()
    Remarks Check whether the printer spooler deamon has been loaded.


    Function Spooler::Submit
    Include file SPOOLER.CPH
    Prototype Spooler::Submit( char *s )
    Remarks Submit( char *s ) - submit a file to the spooler // INP : char *s - the name of the file to spool OUT : int - SS_NORMAL if no errors else an error code NOTE : if the spooler is inactive, then Submit() will copy the entire file to the printer before returning


    Function Spooler::Remove
    Include file SPOOLER.CPH
    Prototype int Spooler::Remove( char *s )
    Remarks Remove specified files from the spooler queue. INP : char *s - file name to remove OUT : SS_NORMAL if no errors, otherwise the error code NOTE : the file specification MAY contain wildcard characters


    Function Spooler::Clear
    Include file SPOOLER.CPH
    Prototype int Spooler::Clear()
    Remarks Clear all the files from the spooler queue. OUT : SS_NORMAL if no errors, otherwise the error code


    Function Spooler::Suspend
    Include file SPOOLER.CPH
    Prototype int Spooler::Suspend()
    Remarks Force the spooler to pause. OUT : SS_NORMAL if no errors, otherwise the error code


    Function Spooler::Resume
    Include file SPOOLER.CPH
    Prototype int Spooler::Resume()
    Remarks Tell the spooler to resume printing. OUT : SS_NORMAL if no errors, otherwise the error code


    Function char
    Include file SPOOLER.CPH
    Prototype char ( far *Spooler::List() )[ 64 ]
    Remarks Retrieve a list of files in the spooler. OUT : char ( * )[ 64 ] - ptr to list 64 character strings holding the names of the files in the queue. If it's NULL, then the queue is empty, and a zero-length string terminates it . NOTE : when you call this function, the spooler is suspended, so Resume() must be called to restart it


    Table of Contents Function Index

    Function Index

    Go to Table of Contents

    GRX_box GRX_grid Graphics_off
    Graphics_on Printer::ClearHeadings Printer::Print
    Printer::PrintHeading Printer::Printer Printer::SetHeading
    Printer::intPrint Printer::~Printer Spooler::Clear
    Spooler::Remove Spooler::Resume Spooler::Spooler
    Spooler::Submit Spooler::Suspend Vector_text
    _inline _pnt _strdate
    _strtime add_2_compress_data_struct adv_x_axis_plot_point
    advance_scrolled_region align_1st_bar alloc_ema
    alloc_macd alloc_sma alloc_stddev
    alloc_stoc alloc_wld_ma alloc_wuo
    allocate_ad allocate_ama allocate_bb
    allocate_cci allocate_chaikin allocate_change
    allocate_data_structures allocate_daytype allocate_dmac
    allocate_dmi allocate_ema allocate_hhigh
    allocate_llow allocate_macd allocate_macdh
    allocate_mathop allocate_max allocate_min
    allocate_mom allocate_nvi allocate_obv
    allocate_par allocate_pchange allocate_pivot_pts
    allocate_pvi allocate_range allocate_recnum
    allocate_roc allocate_rsi allocate_rwi
    allocate_shift_data allocate_sma allocate_srat
    allocate_stddev allocate_stoc allocate_sum
    allocate_sum_n allocate_thigh allocate_tlow
    allocate_trange allocate_trd_signal_routine allocate_trix
    allocate_tslr allocate_wclose allocate_wma
    allocate_wr allocate_wuo allocate_x1
    append_cpt_dt_file auto_select_a_scr bars_needed_by_secondary_srcs
    bios_clear bios_clear_rng bios_home_cursor
    bios_move bios_scroll_area bios_scroll_lines
    bios_set_video_line_attributes bios_vputs bios_vputs_at
    blank_pad_2_length bld_ind_label_str build_axis_incs
    calc_2_freq_trig_reg calc_ad calc_all_cycle_positions
    calc_ama calc_ama_ind calc_avg
    calc_bb calc_bband_ind calc_best_fit_linreg
    calc_blended_cycles calc_cci calc_chaikin
    calc_change calc_cycle_position calc_day_of_week_index
    calc_days_needed calc_daytype calc_dmac
    calc_dmi calc_dt_n_axis_scale_factors calc_dt_range
    calc_ema calc_ema_coeff calc_ema_ind
    calc_emacd calc_fibonacci_expansions calc_fibonacci_retraces
    calc_hhigh calc_linreg calc_llow
    calc_macd calc_macd_ind calc_macdh
    calc_mathop calc_mom calc_mth_idx
    calc_new_price_with_linreg calc_next_trading_date calc_nvi
    calc_ob_os_signal_state calc_obv calc_one_cycle_position
    calc_output_places calc_par calc_par_ind
    calc_pchange calc_percentage calc_pivot_pts
    calc_pvi calc_range calc_recnum
    calc_rev_ob_os_signal_state calc_roc calc_rsi
    calc_rsi_ind calc_rwi calc_rwi_ind
    calc_scr_size_constants calc_shift_data calc_sma
    calc_sma_ind calc_smacd calc_srat
    calc_stddev calc_stoc calc_stoc_ind
    calc_sum calc_sum_n calc_thigh
    calc_tlow calc_trange calc_trix
    calc_tslr calc_tslr_ind calc_ultimate_osc_value
    calc_wclose calc_wma calc_wma_ind
    calc_wr calc_wuo calc_x1
    call_int21_get_disk_data char chk_4_ascii_data_file
    chk_4_file chk_4_label_update_with_defaults chk_4_ma_tests
    chk_4_post_proc_requests chk_4_user_requested_trd_sig chk_cmd_verb_table
    chk_config_args chk_dash_state chk_data_tables
    chk_if_1st_arg_is_a_db_path chk_if_help_was_requested chk_if_holiday
    chk_if_valid_data_source chk_if_we_are_superuser chk_ma_lengths
    chk_this_csi_master_rec clear_data_rec clear_the_out_array
    clear_the_prc_array clear_tm_struct clone_2_far_n_free
    clone_cur_prc_rec close_output_device cmd_ln_args_2_str
    cntl_c_handler cnvt_DATA_REC_2_MINI cnvt_DATA_REC_2_cpt_dt_format
    cnvt_DD_MM_YY_2_flt cnvt_MM_DD_YY_2_YYMMDD_str cnvt_MM_DD_YY_2_flt
    cnvt_YYMMDD_flt_2_DD_MM_YY cnvt_YYMMDD_flt_2_MM_DD_YY cnvt_YYMMDD_flt_2_YYMMDD_str
    cnvt_YYMMDD_str_2_MM_DD_YY cnvt_YYMMDD_str_2_flt cnvt_bond_data_into_decimal
    cnvt_cmd_ln_args cnvt_commas_2_white_space cnvt_cpt_data_rec
    cnvt_csi_data_rec cnvt_cur_idx_2_last cnvt_julian_date_2_MM_DD_YY
    cnvt_julian_date_2_YYMMDD cnvt_julian_date_2_YYMMDD_flt cnvt_julian_date_2_str
    cnvt_line_to_lowercase cnvt_line_to_uppercase cnvt_nl_2_null
    cnvt_null_bytes_2_spaces cnvt_tbond_2_decimal cnvt_tbond_data_rec_2_decimal
    cnvt_tbond_data_rec_dec_to_32 cnvt_tbond_decimal_2_normal cnvt_tbond_vars_if_necessary
    cnvt_tm_struct_2_dostime color color_n_return_cur
    compare_dates compress_cmd_ln compress_day_to_week_or_month
    constant_length_date copy_str_n_blank_pad copy_ticker_str
    correct_CSI_ticker_error create_cpt_data_file create_cpt_dop_file
    csi_2byte_convert csi_3byte_convert csi_points_2_dollars
    day_of_the_week dec_cur_prc_rec define_database
    detrend_data_series direct_disk_read direct_disk_read_fe
    direct_disk_write_2_floppy div_2_kill_time do_fibonacci_crossref
    dostime_2_str dot_tty draw_cmd_chart
    draw_empty_chart draw_y_line dspy_compile_version
    dspy_debug_hook_vars dspy_video_buffered_data dump_TS_cmd_ln_2_output_device
    dump_banner_2_output_device dump_cmd_ln_2_output_device dump_copyright_notices
    dump_cpt_data_file_header dump_csi_data_file_header dump_prc_master_if_debug_flag
    dump_ref_str_if_debug_flag dump_the_data_file_header dump_the_master_file
    dump_ticker_str eat_EQUIS_flag_char eat_commas_except_in_dquotes
    eat_trailing_white_space eat_white_space_in_str echo_2_stdout_if_necessary
    ega_plot_pt empty_cpt_data_file enough_data_yet
    expand_tabs_in_str_2_spaces farrealloc fe_calc_ob_os_signal_state
    fe_set_ind_signal_state fetch_data_field fetch_far_data_rec
    fieeetomsbin final_day_type_analyze final_exit_cleanup
    find_data_rec_by_date_fsearch find_data_record_by_date find_data_source
    find_date_offset find_last_record find_rec_by_date
    find_rec_by_date2 find_ticker_with_wildcard_supp findarg
    finish_regression_calcs fmsbintoieee free_ama_ind_struct
    free_ama_struct free_bband_ind_struct free_bband_struct
    free_cpt_master_file_rec free_data_structures free_freq2_reg_struct
    free_global_vars free_macd_ind_struct free_macd_struct
    free_par_ind_struct free_process_vars free_rsi_struct
    free_rwi_ind_struct free_rwi_struct free_sma_struct
    free_stddev_struct free_stoc_ind_struct free_stoc_struct
    free_tslr_ind_struct free_tslr_struct free_wma_struct
    general_data_store get_circular_index get_config_file
    get_cur_cpt_master_rec get_data_record_n get_data_value
    get_date_substr get_dir_record get_dos_version
    get_drive_num_from_str get_field_from_YYMMDD_flt get_first_int_arg
    get_first_unused_arg get_first_unused_arg_n_mark_used get_first_unused_int_arg
    get_format_str get_highs_and_lows get_jdate_from_user
    get_kybd_scan_code get_kybd_status_bytes get_label_str
    get_label_str_secondary get_last_output_value_4_cur_prc get_logical_sector_number
    get_month_str get_new_cpt_master_rec get_next_data_record
    get_system_time get_time_in_DOS_format get_trade_signal
    get_unused_label_str get_y_plot getargs
    inc_cur_prc_rec increment_secondary_data_ptrs init_ad
    init_ama init_bb init_cci
    init_chaikin init_compress_data_struct init_data_file_temps
    init_daytype init_dmi init_ema
    init_ema_ptr init_forward_data init_global_vars
    init_hhigh init_llow init_macd
    init_mathop init_mom init_nvi
    init_obv init_out_array init_par
    init_process_vars init_pvi init_ran
    init_roc init_rsi init_rwi
    init_scrolled_region init_sdev init_secondary_data_ptrs
    init_shift_data init_sma init_sma_ptr
    init_stddev init_stoc init_sum
    init_sum_n init_trix init_tslr
    init_wld_ma_ptr init_wma init_wuo
    init_x1 insert_str_into_str is_mrk_day
    is_this_a_number_str julian_date label_cmd_chart
    label_ind_x_axis_with_date label_x_axis_as_date label_x_axis_as_date_style2
    label_y_axis ld_ascii_data_file ld_cpt_master_file_into_memory
    ld_holiday_file ld_ind_from_DATA_REC_series line
    lineto ln_to_upper_except_in_dquotes load_cycle_data_file
    load_disk_boot_record load_disk_info_via_ioctl load_last_n_data_records
    load_one_intraday_day load_secondary_data load_the_data_array
    local_exit lookup_ascii_data_file lookup_config_index
    lookup_cpt_data_file_num lookup_csi_data_file_num lookup_data_file_num
    loop_opt main make_data_file_name
    make_dop_file_name make_secondary_label_str match_str_with_wildcard_support
    math_exception_handler matrix_gaussian_elimination mem_lookup_data_file_num
    millisecond_delay mode move_ROM_date_2_str
    my_calloc my_chdir my_clear_memory
    my_farcalloc my_fprintf my_mkdir
    my_rmdir my_unlink new_ama_ind_struct
    new_ama_struct new_bband_ind_struct new_bband_struct
    new_ema_struct new_fibprj_struct new_grfx_struct
    new_linreg_struct new_macd_ind_struct new_macd_struct
    new_par_ind_struct new_par_struct new_rsi_struct
    new_rwi_ind_struct new_rwi_struct new_sma_struct
    new_stddev_struct new_stoc_ind_struct new_stoc_struct
    new_tslr_ind_struct new_tslr_struct new_wma_struct
    normal_cnf_table_store olm_a_file open_data_file
    open_data_file_4_update open_n_load_ascii_data_file output_a_timestamp_msg
    output_ascii_dt_file output_blend_structs output_cpt_dt_file
    output_cur_prc_rec output_data_4_metastock output_one_blend_struct
    output_pending_cycles output_str_2_log_file output_the_out_array
    overlay_line_plot plot_DATA_REC_data plot_float_data
    plot_high_low_bar plot_open_int_line plot_volume_bars
    point pr_usage print_cpt_master_rec
    print_csi_1st_recs print_data_struct print_data_struct_compact
    print_tm_struct process_1_ascii_line process_1_template_line
    process_1_ticker process_blend_dt_rec process_config_file
    process_cycle_data_rec process_cycle_dt_rec process_fib_rpt_line
    process_holiday_rec process_one_config_entry process_one_data_file
    process_paren_assignment process_template_file process_the_data_array
    process_ticker_dt_rec process_ticker_list_file random_int
    read_dop_file report_error_n_exit report_fatal_error
    report_unused_tokens reset_ama_struct reset_bband_struct
    reset_ema_struct reset_fibprj_struct reset_macd_struct
    reset_par_struct reset_rsi_struct reset_rwi_struct
    reset_sma_struct reset_stddev_struct reset_stoc_struct
    reset_temp_grfx_vars reset_tslr_struct reset_wma_struct
    restore_trend_2_data_series return_next_token_str roll_2_tomorrow
    round_as_int rpt_current_state rpt_debug_msg
    rpt_memory_left_if_debug_flag rpt_msg_n_status rpt_template_error
    save_cycle_rec save_output_value save_trade_signal_value
    scale_data_rec scr_call set_cmd_line_flags
    set_cpt_output_places set_data_labels_complex set_data_source_complex
    set_data_source_n_labels set_database_flags set_database_vars
    set_equivolume_scale_factors set_f_scaler set_file_rec_numbers
    set_high_lows set_ind_signal_state set_kybd_status_bytes
    set_line_2_dashed set_line_2_solid set_ob_os_ind_signal_state
    set_output_formats set_output_params set_plot_range
    set_ptrs_2_next_day set_token_flags set_token_ptrs
    set_trade_signal_state set_x_inc set_y_inc
    setarg shift_moving_average special_token_saves
    stoi store_1_scr_sizes store_a_fib_node
    store_a_fib_projection store_bars_needed store_csi_1st_rec_data
    store_data_field store_holiday_rec store_ind_in_DATA_REC_series
    store_stoc_data strcmp_fr_2_fr strcpy_fr_2_fr
    string_copy strncpy_fr_2_fr strncpy_n_blank_pad
    strncpy_n_uppercase_it submit_a_file support_chart_movement
    test_find_rec_by_date tick_x_axis tick_y_axis
    time_stamp tm_2_MM_DD_YY trim_trailing_white_space_2_cnt
    update_ama_struct update_bband_struct update_cpt_data_record
    update_cpt_dt_file_reccnt update_cpt_master_file update_cpt_master_file_cnts
    update_db_module_vars update_ema update_ema_struct
    update_macd_struct update_par_struct update_rsi_struct
    update_rwi_struct update_scrolled_region update_sma
    update_sma_struct update_stddev update_stddev_struct
    update_stoc_struct update_trade_signal_state update_tslr_struct
    update_wld_ma_ptr update_wma_struct validate_MM_DD_YY
    validate_boolean_answer validate_data_path_str validate_data_type
    validate_date_field validate_primary_verb validate_with_str_array
    validate_with_str_array_stricmp


    Table of Contents Function Index

    generated on 08 February 1998 - 14:53:12
    © 1998 Tierra del Fuego Ltd.