QwntmLeap

Strategies

A strategy is one Python file written in a fixed template, the way Pine Script works in TradingView.

The template

from tc_strategy import Strategy, Param, Buy, Sell, Close


class MyStrategy(Strategy):
    name = "My Strategy"
    warmup = 200  # closed candles needed before the first decision
    params = {"fast": Param.int(9, min=2, max=200, label="Fast EMA")}

    def on_bar(self, ctx):  # runs each time a candle closes
        return []  # or a list of signals

What a strategy can ask for

  • Buy and Sell, each with a required stop loss and optional take-profits.
  • Close to close its own trades, and MoveStops to trail or move break-even.
  • There is no lot size: it is worked out from the risk percentage you set when you deploy, and the stop distance.

Every signal is checked again against your risk limits. A refused signal is logged with the reason, and three refusals in a row stop the strategy. A strategy can only touch its own trades, never your manual ones.

The sandbox

Strategies run in a sealed box: no network, no files, no access to MetaTrader 5 or the app's data, and limited memory and time (5 seconds per candle). Only a short list of libraries can be imported, including math, statistics, numpy and pandas.

Demo first

Strategies must run on a demo account before they can be approved for live trading.