Algorithmic Trading Strategy & Development

We've spent over a decade building trading bots for a living. Hundreds of them. Some were brilliant. A few blew up accounts – including two of our own. And the single biggest lesson from all of it?
The traders who automate eat the ones who don't.
That's not marketing. That's math. Algorithms don't panic at NFP releases. They don't hold a loser "just one more candle." They don't revenge-trade. And they sure as hell don't fall asleep during London open.
This is the foundation article is going to take you from zero to live deployment. Not theory – real code, real strategies, real war stories. Let's get into it.
Strip away the jargon and it's this: you write rules, a computer follows them. That's it.
The rules can be dead simple -
"Buy when the 20 EMA crosses above the 50 EMA. Sell when it crosses back."
Or they can be the kind of thing that keeps you up at night debugging -
"Open 8 correlated FX positions simultaneously, size each lot dynamically off equity, hedge adverse moves on the fly, and flatten everything when combined P&L hits target."
Both are algo trading. One took us an afternoon. The other took three months and probably shaved a year off our lives. But the machine doesn't care how complex the logic is. It just runs.
You're slow. An algorithm reacts in milliseconds. You need seconds to spot a signal, process it, and click. In a fast tape, those seconds are money burning.
You're emotional. You hold losers because admitting the trade was wrong hurts. You cut winners because the green P&L feels fragile. You revenge-trade after a loss because your lizard brain demands it. We've done all of these things. An algorithm hasn't, because it can't.
You can't scale. You watch two, maybe three charts. A bot monitors fifty – across timeframes – and executes on every single one without breaking a sweat.
You can't test yourself. Before we risk a dollar, we test against five years of data. We know the win rate, the drawdown, the profit factor. All before placing one live trade. Try doing that with your gut feeling.
You need sleep. Forex runs 24/5. Crypto runs 24/7. You don't.
We get asked "what platform should I use?" more than any other question. The answer depends on what you trade, how technical you are, and honestly, how much pain you're willing to tolerate.
Here's the honest breakdown. Not the one you'd read on a comparison site – the one from someone who's shipped production code on all six.
| Market | Forex and CFDs |
| Language | MQL4 or MQL5 - C-like, proprietary, quirky |
| Why people love it | Every forex broker supports it. The community is enormous. Free. |
| Why it'll frustrate you | Stuck in forex-land, mostly. The language has its… moments. |
MT4 is the cockroach of trading platforms. It refuses to die, and for good reason – it just works. If you're trading FX, this is still where most of the action is. The EA system isn't glamorous, but we've built multi-currency arbitrage bots in it that ran for years without a hiccup.
// A basic MQL4 EA structure
int OnInit() {
Print("EA initialized on ", Symbol());
return INIT_SUCCEEDED;
}
void OnTick() {
// Your trading logic runs here, every price tick
double ema_fast = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0);
double ema_slow = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, 0);
if (ema_fast > ema_slow && OrdersTotal() == 0)
OrderSend(Symbol(), OP_BUY, 0.1, Ask, 3, 0, 0, "EMA Cross", 12345);
}
| Market | Everything - stocks, crypto, forex, futures |
| Language | Pine Script v5 - Python-ish, beginner-friendly |
| Why people love it | Gorgeous charts. Ridiculously easy to learn. Instant backtesting. |
| Why it'll frustrate you | Can't execute trades natively. You need a webhook bridge to actually do anything with your signals. |
TradingView is where we prototype. If an idea can't survive a quick Pine Script test, it doesn't deserve three days of MQL4 development. Think of it as the napkin sketch before the engineering blueprint.
//@version=5
strategy("EMA Crossover", overlay=true)
ema_fast = ta.ema(close, 20)
ema_slow = ta.ema(close, 50)
if ta.crossover(ema_fast, ema_slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(ema_fast, ema_slow)
strategy.close("Long")
| Market | Anything you can get data for - crypto, stocks, forex, futures, options |
| Language | Python + libraries (backtrader, ccxt, pandas, alpaca-py) |
| Why people love it | Total freedom. Connect to any exchange, any data source. ML integration. |
| Why it'll frustrate you | You build everything from scratch. No charting platform. No hand-holding. |
Python is what we reach for when MT4 isn't enough. Need to backtest a portfolio strategy across 30 stocks? Python. Want to feed machine learning signals into a crypto bot? Python. It's the Swiss army knife – but you have to know which blade to pull out.
import backtrader as bt
class EMACross(bt.Strategy):
params = dict(fast=20, slow=50)
def __init__(self):
self.ema_fast = bt.ind.EMA(period=self.p.fast)
self.ema_slow = bt.ind.EMA(period=self.p.slow)
self.crossover = bt.ind.CrossOver(self.ema_fast, self.ema_slow)
def next(self):
if self.crossover > 0:
self.buy()
elif self.crossover < 0:
self.close()
| Market | Futures, forex, US equities |
| Language | C# wrapped in NinjaTrader's API |
| Why people love it | Institutional-grade execution. Superb for futures. Free platform. |
| Why it'll frustrate you | Steeper learning curve. Smaller community. C# feels heavy if you're used to scripting languages. |
If you trade E-mini S&P or crude oil futures and you're not on NinjaTrader, you should look into it. The order routing and market analysis tools are legitimately best-in-class.
protected override void OnBarUpdate()
{
if (CrossAbove(EMA(20), EMA(50), 1))
EnterLong("EMA Cross Long");
if (CrossBelow(EMA(20), EMA(50), 1))
ExitLong("EMA Cross Exit");
}
| Market | US stocks, options, some forex |
| Language | ThinkScript - declarative, compact, unique |
| Why people love it | Free with Schwab account. Killer options analysis. Solid scanner. |
| Why it'll frustrate you | "Automation" is a stretch. You get studies, alerts, and conditional orders – not full bot execution. |
TOS is that friend who's really smart but won't commit. The analysis tools are phenomenal. The scripting language is capable. But when it comes to actually pulling the trigger automatically? You're mostly on your own with alerts and conditional orders.
def ema_fast = ExpAverage(close, 20);
def ema_slow = ExpAverage(close, 50);
plot signal = if ema_fast crosses above ema_slow then 1
else if ema_fast crosses below ema_slow then -1
else 0;
| Market | Multi-asset - stocks, forex, futures on one platform |
| Language | MQL5 - OOP evolution of MQL4 |
| Why people love it | Handles multiple asset classes. Faster backtester. Netting + hedging modes. |
| Why it'll frustrate you | Not a drop-in replacement for MT4. Different syntax. Not all brokers have migrated. |
Think of MT5 as MT4's more ambitious sibling. If you need stocks and forex on the same platform, MT5 is the move. If you're pure forex and your broker supports MT4? Stick with MT4. No reason to make your life harder.
Pretty much anything with clear rules. Over the years, we've built bots for every category below – and we've got opinions on all of them.
| Strategy | What it does | Our take |
|---|---|---|
| Trend Following | Ride the wave with EMAs, MACD, ADX. | The "boring but profitable" category. Most of the money in algo trading is made here, and most beginners skip it because it's not sexy enough. |
| Mean Reversion | Bet on rubber-band snapback using Bollinger Bands, RSI extremes, or Z-scores. | Works beautifully in ranging markets. Gets obliterated in trends. |
| Breakout | Price escapes a level, you jump on. Donchian channels, fractal pivots, session ranges. | The trick is filtering the fakes from the real moves. We'll spend multiple articles on this. |
| Scalping / HFT | Lots of trades, tiny wins, tight stops. | You need razor-thin spreads and fast execution. We like building these, but they're the most fragile in production. One spread widening and your edge evaporates. |
| Arbitrage | Exploit mispricings between correlated instruments. Basket trading across 8 currency pairs, for instance. | Not as glamorous as it sounds – the edges are thin and the margin requirements are real. |
| Grid Trading | Orders at fixed intervals above and below price. Profits from oscillation. | Makes money until it doesn't, and when it stops, the drawdown is nuclear. We've built these for clients. We wouldn't run one ourselves. |
| Session-Based | Trade the open, the close, the Asian range, the London break. | Some of the most reliable edges we've seen live in specific time windows. |
| Elliott Wave / Pattern Recognition | Automated wave counting with ZigZag + custom detection. | Fascinating to build. Maddening to optimize. We have a whole article on this one. |
Whether you hire our team or go solo, the process looks the same. Nobody skips stages – or if they do, the market teaches them why that was a bad idea.
Stage 1 – Design: Nail down the rules before you touch code. What triggers entry? Where does the stop go? How do you size the position? What keeps you out of bad trades? If you can't answer these on paper, you can't answer them in code.
Stage 2 – Code: Translate rules into your platform. A solid EA runs 300–500 lines of MQL4. Pine Script tends shorter. Python can balloon if you're doing the full data-pipeline-to-execution chain.
Stage 3 – Backtest: Throw three to five years of data at it. Minimum. Not "let me find the date range where it looks good." The full ugly picture. You want to know profit factor, max drawdown, win rate, expected payoff, and Sharpe ratio. If any of those make you wince, go back to Stage 1.
Stage 4 – Optimize (Carefully): Tweak parameters. But here's where most people destroy themselves – they optimize until the backtest looks incredible, then go live and get crushed. Because they didn't fit a strategy to the market; they fit the market to a strategy. Walk-forward analysis is non-negotiable. We'll cover that in depth later.
Stage 5 – Paper Trade: Live data, fake money. One to three months. This catches all the things backtesting can't: connection drops, spread widening, timezone bugs, that weird thing your broker does with partial fills at 5 PM EST.
Stage 6 – Go Live: VPS. Minimum position size. Nervous energy. Scale up slowly as the numbers hold. Not before.
We put this near the end on purpose. Because by now you're excited about strategies and platforms, and we need you to slow down for sixty seconds.
Every blown account we've seen – ours included – had the same root cause. Not a bad strategy. Bad risk management. Or no risk management.
Nothing goes live without these:
| No. | Rule | Why |
|---|---|---|
| 1 | ATR-based stops | Stop distance adapts to volatility. Tight in quiet markets, wide in wild ones. |
| 2 | Percentage-based sizing | Risk 1–2% of your account per trade. Not "whatever feels right." |
| 3 | Drawdown circuit breaker | Equity drops below a threshold? Bot stops trading. Period. |
| 4 | Daily trade cap | Overtrading kills more accounts than bad entries. |
| 5 | Spread filter | Spreads blow out at news time and midnight. The bot should sit on its hands. |
| 6 | Session filter | Liquid hours only. That 3 AM entry on USD/JPY isn't a signal, it's noise. |
| 7 | Trailing stops | Lock profits. Let winners breathe but don't give it all back. |
| 8 | Margin check | Don't let the bot open a position it can't afford. |
These aren't advanced features. They're seatbelts. Skip them and it's not a question of if you crash – it's when.
Look – not everyone wants to code. Some of you have a strategy that prints money manually and just need a developer who won't screw it up in translation. That's literally what Quantumcona does.
We've shipped 100+ production algorithms across MT4, MT5, TradingView, Python, and NinjaTrader. Strategy design, backtesting, optimization, deployment – the whole pipeline.