forge.signals

Forge API 1

What ``compute()`` returns: ``fg.Signals``, and named conditions built with ``fg.all_of``.

``compute(self, d)`` gives Forge whole arrays of entry and exit conditions. Forge turns them into orders without calling Python on every bar. Entry and exit fields are True/False numpy arrays the length of the strategy's bars, or condition trees whose names are kept so a bar can say which conditions were true.

NameKindSummary
AddOnclassAdd to a position that moved in its favour: ``fg.AddOn(every_pips=20, size_mult=0.5)``.
BracketfunctionAn entry order with its stop and its target: ``fg.Bracket(entry, sl, tp)``.
BreakEvenclassMove the stop to the entry price once the trade is ahead: ``fg.BreakEven(at_r=1.0)``.
CapsclassThe most a strategy may hold or risk: ``fg.Caps(max_lots=2, max_positions=3)``.
EntryclassHow entries are placed: ``fg.Entry.market``, ``limit``, ``stop`` or ``stop_limit``.
ExitclassThe ways to close trades together or by time: ``fg.Exit.basket``.
FilterclassFilters for ``fg.Signals(filters=[...])`` and the class attribute ``filters``: where not to trade.
OrderclassThe orders ``ctx.order`` takes: ``fg.Order.market``, ``limit``, ``stop`` and ``stop_limit``.
PlotclassA named series for ``fg.Signals(plots=...)`` with a style and a pane.
RegionclassA stretch of bars to shade on the chart: ``fg.Region(start, end, label="news")``.
SignalsclassWhat ``compute()`` returns: entry and exit conditions, and named series to plot or record.
SizeclassHow much each entry trades.
StopclassWhere a losing trade is closed.
TargetclassWhere a winning trade is closed.
TargetsclassSeveral targets that each close a part of the trade: ``fg.Targets([(0.5, t1), (0.5, t2)])``.
TimeStopclassClose a trade that has been open too long: ``fg.TimeStop(bars=48)`` or ``duration="2d"``.
TrailclassA stop that follows the price.
all_offunctionTrue on a bar where every named condition is true.
any_offunctionTrue on a bar where at least one named condition is true.
countfunctionThe number of bars among this bar and the ``over - 1`` before it where the condition is true.
n_offunctionTrue on a bar where at least ``k`` of the named conditions are true.
none_offunctionTrue on a bar where none of the named conditions is true.
thenfunctionTrue where ``second`` becomes true, if ``first`` became true 1 to ``within`` bars earlier.
votefunctionTrue from the bar the weighted share of true conditions reaches ``open_at`` percent until the bar it falls to ``close_at`` percent or below.