TulipCharts / tulipindicators

Technical Analysis Indicator Function Library in C
https://tulipindicators.org/
GNU Lesser General Public License v3.0
841 stars 157 forks source link

Generate more boilerplate for indicator implementations #52

Closed rdbuf closed 5 years ago

rdbuf commented 5 years ago

Currently, indicators.tcl will create a template for any newly introduced indicator ind for which indicators/ind.c doesn't exists, yet it doesn't use available info in full and makes us write some things by hand.

This patch automatically generates code for input and output variables. Sample generated code for lappend indicators [list overlay "Example" example 1 1 1 {real} {period} {example}]:

/*
 * Tulip Indicators
 * https://tulipindicators.org/
 * Copyright (c) 2010-2019 Tulip Charts LLC
 * Lewis Van Winkle (LV@tulipcharts.org)
 *
 * This file is part of Tulip Indicators.
 *
 * Tulip Indicators is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * Tulip Indicators is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Tulip Indicators.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "../indicators.h"

int ti_example_start(TI_REAL const *options) {

}

int ti_example(int size, TI_REAL const *const *inputs, TI_REAL const *options, TI_REAL *const *outputs) {
    TI_REAL const *real = inputs[0];
    const TI_REAL period = options[0];
    TI_REAL *example = outputs[0];

    #error "CODE GOES HERE"

    return TI_OKAY;
}
codeplea commented 5 years ago

Looks good to me.