algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::strategy::vanilla::MovingAverageCrossover Struct Reference

Holds quantity_ shares while the fast moving average is above the slow one, and is flat otherwise. More...

#include <algotradelib/src/strategy/vanilla/crossover.hpp>

Collaboration diagram for algotradelib::strategy::vanilla::MovingAverageCrossover:

Classes

struct  Params
 The strategy's settings. More...

Public Member Functions

std::size_t warmup_bars () const
 Returns how many bars to load before the first live bar.
template<class Ctx>
void on_bar (Ctx &ctx, const BarEvent &bar)
 States the target position for the instrument on each of its bars.

Public Attributes

Params params_
 The settings.

Detailed Description

Holds quantity_ shares while the fast moving average is above the slow one, and is flat otherwise.

On every bar it states a target position (the level, not a crossing event), so it keeps no state and behaves the same after a restart.

Definition at line 47 of file crossover.hpp.

Member Function Documentation

◆ on_bar()

template<class Ctx>
void algotradelib::strategy::vanilla::MovingAverageCrossover::on_bar ( Ctx & ctx,
const BarEvent & bar )
inline

States the target position for the instrument on each of its bars.

Template Parameters
CtxThe runner's context type.
Parameters
ctxThe context.
barThe new bar.

Definition at line 80 of file crossover.hpp.

Referenced by algotradelib::strategy::vanilla::EmaCrossover::on_bar(), and algotradelib::strategy::vanilla::SmaCrossover::on_bar().

◆ warmup_bars()

std::size_t algotradelib::strategy::vanilla::MovingAverageCrossover::warmup_bars ( ) const
inline

Returns how many bars to load before the first live bar.

Returns
slow_ + 1; the strategy acts only once that many closes are cached.

Definition at line 71 of file crossover.hpp.

Referenced by on_bar(), algotradelib::strategy::vanilla::EmaCrossover::warmup_bars(), and algotradelib::strategy::vanilla::SmaCrossover::warmup_bars().

Member Data Documentation

◆ params_

Params algotradelib::strategy::vanilla::MovingAverageCrossover::params_

The settings.

Definition at line 65 of file crossover.hpp.

Referenced by on_bar(), and warmup_bars().


The documentation for this struct was generated from the following file: