Signature Description Parameters
#include <DataFrame/DataFrameFinancialVisitors.h>

template<typename T, typename I = unsigned long>
struct ArnaudLegouxMAVisitor;

// -------------------------------------

template<typename T, typename I = unsigned long>
using alma_v = ArnaudLegouxMAVisitor<T, I>;
        
This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.

This visitor calculates the rolling values of Arnaud Legoux Moving Average. It requires 1 input column.
The result is a vector of values with same number of items as the given column. The first roll_count items, in the result, will be NAN.
The ALMA is a technical analysis tool that aims to give investors and traders a more reliable trading signal by reducing the noise that can interfere with traditional moving averages. It eliminates the small fluctuations in an asset price to make the trend clearer. The ALMA reduces price lag and creates a smoother line than other moving averages. Rather than a straightforward moving average for a certain period, it applies a moving average twice – from left to right as well as right to left.
    explicit
    ArnaudLegouxMAVisitor(size_t roll_count = 10, T sigma = 6.0, T dist_offset = 0.85)

    roll_count: Moving average period
    sigma: The standard deviation applied to the combo line. It makes the combo line sharper.
    dis_offset: Offset is the Gaussian applied to the combo line and it is 0.85 by default.
                Setting offset at 1 makes it fully aligned to the current price just
                like the exponential moving average.
        
T: Column data type
I: Index type
static void test_ArnaudLegouxMAVisitor()  {

    std::cout << "\nTesting ArnaudLegouxMAVisitor{  } ..." << std::endl;

    typedef StdDataFrame<std::string> StrDataFrame;

    StrDataFrame    df;

    try  {
        df.read("data/SHORT_IBM.csv", io_format::csv2);

        alma_v<double, std::string> alma;

        df.single_act_visit<double>("IBM_Close", alma);

        assert(alma.get_result().size() == 1721);
        assert(std::isnan(alma.get_result()[0]));
        assert(std::isnan(alma.get_result()[9]));
        assert(std::abs(alma.get_result()[10] - 187.533) < 0.001);
        assert(std::abs(alma.get_result()[14] - 186.359) < 0.001);
        assert(std::abs(alma.get_result()[25] - 176.892) < 0.001);
        assert(std::abs(alma.get_result()[1720] - 117.841) < 0.001);
        assert(std::abs(alma.get_result()[1712] - 127.677) < 0.001);
        assert(std::abs(alma.get_result()[1707] - 121.435) < 0.001);
    }
    catch (const DataFrameError &ex)  {
        std::cout << ex.what() << std::endl;
    }
}
C++ DataFrame