Trend Following (Algo) Strategy

The premise of this strategy is that whatever is happening will continue happening (especially when it comes to a strong trend). In this example, I’m using 5 consecutive green candles as an indicator of a strong trend. Because something is obviously causing such a clear move in one direction. entry position (white dot) and exit position (yellow square) The code In the code below, using […]

Read More...

Predicting Target/Stop Prices With Neural Network

(this is part 8 of the “AI for Finance Course“) Now we’re going to combine the candle pattern recognition with the actual target/stop outcomes and see how well the neural net performs. Because predicting the next candle is irrelevant if the entire price (over many candles) goes in a different direction. Instead, now the plan is to take 3 by 3 candles and see where […]

Read More...

Recognizing Candle Patterns Using Neural Network

(this is part 7 of the “AI for Finance Course“) Some people believe candlestick patterns help predict market movements, so let’s test it and see if they’re correct. Here are some patterns mentioned on wikipedia: (screenshot from wikipedia) While these might hold value we’re not going to hardcode them. Instead, we’re going to let our neural net recognize them on its own. Those patterns might […]

Read More...

Neural Network Market Predictions

(this is part 6 of the “AI for Finance Course“) Now that we can see how a single neuron performs when dealing with real market data, it’s time to test a multi-neuron network. Everything is the same as before, we just now have 3 neurons and 2 layers: And obviously we have 3 inputs that we’re passing to our network (i.e. candle data: high, low, […]

Read More...

Limits of The Single Neuron (AI)

(this is part 3 of the “AI for Finance Course“) In previous lesson, we saw significant improvements when it comes to handling low input values (including zero). However this is by far the end of the complexity we can find in our data. In fact, it’s the beginning. Just take a look at these inputs: double[][] inputs = [ [0.0, 0.0], // 1 [0.0, 1.0], […]

Read More...

Multi-Neuron Network Explained (AI)

(this is part 4 of the “AI for Finance Course“) In our previous lesson we discussed how a single neuron cannot properly learn linearly non-separable data, and now we’re going to fix it. FYI, here are the predictions from a (trained) single neuron: // [0, 0] : 0.156053 –> 1 // [0, 1] : 0.5 –> 0 // [1, 0] : 0.843947 –> 0 // […]

Read More...

Crucial Part Of The Neuron (AI)

(this is part 2 of the “AI for Finance Course“) Previously, you might have seen how the most basic form of a neuron simply cannot handle all the data that is thrown at it, specifically low values. This means, if both of our inputs are zero, regardless of how good our weights are tuned, the sum will always be zero.(and consequently, sigmoid function will always […]

Read More...

Single Neuron Explained (AI)

(this is part 1 of the “AI for Finance Course“) Imitating nature is always a good way to make technical progress. Airplanes copied birds, submarines copied fish, and neural networks copied the brain. 🧠 Or at least they were inspired by it. The left side represents sensory inputs where signals are received. And the right side represents the output where signal is emitted. Obviously, not […]

Read More...

AI for Finance Course (FREE)

no complex math✅no derivatives & integrals✅elementary school math✅plain old english✅no signups & newsletters✅everything is here⬇️⬇️ (powered by my drawing “skills”) This is a series of blog posts covering neural network price predictions 📈, everything from a single neuron to a more complex structure. We will go from “do you know how to multiply 2 numbers” to building a fully-fledged AI bot that can trade LIVE […]

Read More...

Single Neuron Market Predictions

(this is part 5 of the “AI for Finance Course“) Now we can apply all we’ve learned so far and train a single neuron (perceptron) to predict real market (Bitcoin) price. The most simple thing we can do is to use previous candle to predict the next candle. And we’re not going to complicate much with the exact price. We’re just going to try to […]

Read More...

Candle Counting (Algo) Strategy

In random events, “streaks” have low probability, and this strategy is trying to take advantage of this fact by betting against the “streak”. Here we see 3 consecutive red candles before the algorithm enters the trade: entry position (white dot) and exit position (yellow square) The code // CANDLE COUNTING STRATEGY bool hasOpenPosition() { return this.positions.length != 0 && this.positions[$-1].action == Action.OPEN; } override bool […]

Read More...

Moving-Average Crossover (Algo) Strategy

Moving-average crossover strategy assumes that we can detect the change in overall trend by catching it early on a shorter time frame. entry position (white dot) and exit position (yellow square) The code In the code, using the Badger algo-bot starter code, we’re comparing 10 and 20-candle moving average (those are 1-minute candles). First we need to verify that the ma10 is below the ma20. […]

Read More...

Price Percentile (Algo) Strategy

Similar to local minimum strategy, the idea is to wait for price to go somewhat to the extreme and then wait for pullback/retracement. The degree to which you want the price to go to extreme (before entering the trade) is completely up to you. In this code example using the Badger algo-bot starter code, I set the percentile to 20% (i.e. when price was at […]

Read More...

Local Minimum (Algo) Strategy

This strategy is based on the assumption that the price tends to reverse/retrace from extremes and this algorithm captures such behavior. When the price reaches local minimum (20 candles), the trade is executed, expecting the price correction in opposite direction. entry position (white dot) and exit position (yellow square) The code Below is the code that uses Badger algo-bot starter code for backtesting and visualization: […]

Read More...

Buy And Hold (Algo) Strategy

The simplest code example for Badger algo-bot starter code is “buy and hold” strategy where your main focus is picking a good entry point. This code example picks the entry point at random (at the beginning of the backtestPeriod). entry position (white dot) and exit position (yellow square) But you can decide based on variety of factors like: local minimum/maximum, price percentile, moving-average crossover, etc. […]

Read More...

Algo-Bot Starter Code

If you ever tried to develop your own algo-trading bot, you quickly realized that building “trading logic” is the last step that comes after you first deal with: All of these boring and tedious (but unavoidable) tasks need to be done BEFORE you can have fun with your algorithms and trading ideas. Personally, it took me over a month (full time) to design and develop […]

Read More...

The Best Programming Language For Finance

You’ve probably never heard of it, but it’s D or Dlang. A programming language with the simplicity of Python and speed of C (or extremely close to it). I used it to build all my algo-trading bots as well as to create algo-bot starter code. Plus, to demonstrate how fast, simple, and powerful Dlang really is, I published a (FREE) AI For Finance Course. And […]

Read More...

Separating Training And Testing Sets

(this is part 9 of the “AI for Finance Course“) This lesson is important because you will almost never be in a situation where you will use the same data for training and prediction. Especially in finance. You can only learn on historical data and make predictions on the new/upcoming data in the future. Simply put: you cannot train your model on price action from […]

Read More...

AI Model Optimization And Next Steps

(this is part 10 of the “AI for Finance Course“) In this (final) lesson you will see how changing things outside the model (like risk levels) can affect the model performance. In the previous lesson we saw the performance of the model where the price target was +0.3% and stop loss was -0.5% —————————- | PERFORMANCE | —————————- – Initial capital: 100000.00 – Final capital::: […]

Read More...