Broker API HubMenu

Trading techniques explained as code

Textbook techniques people have written about for decades, each as a short Python script you can read and run, with a plain account of how it fails. 11 techniques, 16 scripts, standard library only.

Independent and unofficialEducational onlyInvented data onlyCode run

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Teaching material only. This page explains how a technique works as code and how to test an idea honestly. It is not investment advice, not a recommendation and not an invitation to trade. Every price on it is invented, so no result here says anything about any real market, and nothing here suggests that a technique makes money.

Read this one first

Every test on these pages can mislead the person running it. One page shows how, mistake by mistake, on prices that have nothing in them to find. It will change how you read all the others.

Following a trend

Rules that wait for a move to begin and then go with it.

Measuring risk

Not rules for what to trade, but arithmetic for how much and where to stop.

Reverting to an average

Rules that treat a stretched price, or a stretched gap, as something that will come back.

Testing honestly

How a test misleads the person running it, shown on data with nothing in it to find.

Families are in alphabetical order and techniques are in name order within each. The order is not a ranking and no technique here is recommended over another.

The rules every script follows

The invented data

Save these beside a script and run it with Python from that folder. Nothing else needs to be installed.