paint-brush
Developing Your Own Trading System: A Step by Step Logical Guideby@julian-molina
12,882 reads
12,882 reads

Developing Your Own Trading System: A Step by Step Logical Guide

by Julian MolinaSeptember 9th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Julian Molina is co-founder of Superalgos.org, an open-source project building a Collective Trading Intelligence. He lays out a rational framework for developing your trading system by dissecting trading logic, step by step. Following a specific, well thought out and logical scheme is instrumental to avoid falling in the trap of making rushed emotional decisions in the middle of the heat, which most times leads to disastrous results. A solid system also allows traders to be methodical, which is a prerequisite for learning through repetition.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - Developing Your Own Trading System: A Step by Step Logical Guide
Julian Molina HackerNoon profile picture

Laying out a rational framework for developing your trading system by dissecting trading logic, step by step.

I’m sure you’ve heard before that trading is all about developing your system and sticking to it.

Indeed, following a specific, well thought out and logical scheme is instrumental to avoid falling in the trap of making rushed emotional decisions in the middle of the heat, which most times leads to disastrous results.

A solid system also allows traders to be methodical, which is a prerequisite for learning through repetition.

Following a method allows internalizing the thought process, making certain aspects of trading second nature. This frees up traders' mental capacity, which can be devoted to creative processes instead.

With practice comes mastery. With mastery comes knowledge. With knowledge comes strength.—Marvel's Iron Fist

Moreover, a proper logical method is the first and foremost requirement to make every trader’s dream come true: automated trading. Automating random, creative processes is rather challenging, while automating logical, methodical processes is straightforward.

So, what does such a system look like?

What kind of wizardry or black magic is in order?

There is no magic.

It’s pure logic.

I will take you through a step by step analysis that you should be able to follow and understand. It doesn’t involve any high-level industry secret or guru-kind of skills. It relies on simple logic instead.

I will lay out a framework, starting with the basics. I will then dissect the logic behind trading strategies, discuss how to build them and propose how to use them.

You can think of this framework as a structure that can be further optimized by producing additional analysis on top. In fact, what I will cover in this article is Level One — the basics.

If you are a bit lost with strategies, Technical Analysis or are still trying to crawl your way up the learning curve, understanding this framework will put you in the right mind space and will provide you with a solid foundation for your trading education.

The purpose of this framework is to provide you with an understanding of how to develop your trading system, on which you can keep building as you advance in your trading career.

The Basics

In terms of structure, you can think of a trading system as a hierarchical arrangement organizing the actionable aspects of your investment plan.

The structure would be quite large and complex if you were an Investment Bank but can be rather simple for traders just starting.

The framework I will discuss allows for building more complexity at a later moment, as your trading experience develops and you get ready to implement more comprehensive processes.

I will occasionally mention and touch on aspects that have to do with your Investment Plan. However, you will notice I will systematically avoid discussing the plan itself, as the scope of this article is the actual framework for your trading system. Dozens of books have been written on each of the topics that I will choose to skip, so please accept the narrow focus of the article from the get-go.

Capital

The first order of things is determining how much money you will be working with. This is your initial capital.

I won’t go into details on how to determine this number or offer any kind of advice. Those kinds of concerns are out of the scope of this piece, as I wish to focus on the framework itself.

So, it is up to you to determine what capital you will use for trading. The point to take home here is that there is a finite amount of capital.

You will need to manage this capital.

You will need to preserve it.

And you will aim to increase it.

Market

The market refers to the pair of assets you wish to trade with, for instance, BTC-USD, ETH-BTC, etc.

Again, there are many reasons why you may prefer a market over others. Liquidity, volatility, the likability of the underlying project… you name it.

The matter of choosing a market is out of the scope of this piece too, so let’s move on taking home the following point: choosing a market is a strategic decision that you need to make, and — of course — you are free to choose more than one.

Base Asset

The third order of things is deciding what your base asset is. That is, what asset you wish to stand on when you are out of the trade, with no open positions.

For instance, let’s assume you see the outcome of your trading as your retirement bonus. You are also a crypto-believer and are long-term bullish on bitcoin. Chances are you may want to accumulate bitcoin. That is, your base asset is bitcoin.

Needless to say, you may have a valid argument for picking any other or any number of base assets.

Your Investment Plan

As you may have noticed, these three elements — capital, market and base asset — are an integral part of your investment plan.

The plan is yours because it needs to respond to your needs.

That is the main reason why simply copying ideas or attempting to follow the trading of random people wouldn’t necessarily work for you — no matter what mega-following your trading hero may have on Twitter.

Your plan needs to serve your purpose and only you know what your purpose is.

Your plan may have any number of goals (e.g. accumulating bitcoin, diversifying on a basket of coins, annual profit targets, etc.), and you may need to develop individual plans to achieve each of those goals.

This leads us to the concept of strategies.

Strategies

A methodical framework would define a strategy as a set of actions occurring in stages, designed to achieve a specific goal within a broader plan, via executing trades.

Let’s start by dissecting this definition…

A "set of actions occurring in stages" refers to the structure of a strategy. The actions occur in stages because certain actions may be grouped, and each group of actions may be played in a specific sequence.

This concept is fundamental to the methodical aspect of the system, as it provides a framework to run every strategy with the same logic, which certainly contributes to developing a scalable system that may grow to any number of strategies.

The second important bit in the definition of a strategy is “designed to achieve a specific goal within a broader plan”.

One specific goal.

If you attempt to achieve two different goals with a single strategy, you may run into problems. What if the two goals were antagonistic? You could argue solutions may still be found, but the strategy would certainly be more complex.

In any case, the logical thing to do is to analyze each goal separately so that you can design at least one clear, straightforward strategy for each goal.

Now, can you have more than one strategy to achieve a single goal?

Certainly! There are many roads to Rome!

In fact, the norm is to work with several strategies at the same time, as this usually leads to identifying more trading opportunities.

The set of rules and formulas comprising the strategy can be anything. They may be based on Technical Analysis, incorporate fundamentals or sentiment data or anything else you may think of.

Again, I’m not going to discuss any particular indicator or strategy in this piece but will instead focus on the framework, that is, the generalization of the trading process.

Suffice to say that your strategies will be somehow related to the market that you chose to trade in and that they will have several characteristics which I will discuss as I move on with this analysis.

Finally, I will refer to the third section of the definition of strategy “via executing trades”, which leads us to the concept of "a trade".

A trade is a process that exchanges the base asset for a second asset and that — after some time — exchanges back the second asset for the base asset. The first and foremost rule of a trade is to preserve capital and its main goal is to increase it.

This means you will have rules that indicate when to sell your base asset and when to buy your base asset back.

Preserving capital is one of the key rules of becoming a successful trader, as you will probably have as many good trades as bad ones. The trick is that your good trades should end up accumulating more profits than the losses you accumulate with your bad trades.

In terms of its goal, a trade is engaged for the prospect of increasing the quantity of a given base asset.

In other words, you trade in the hope that — during the trade — the second asset will revalue against the base asset so that by the time the second asset is exchanged back for the base asset, the resulting quantity of base asset is bigger than the original.

For instance, let’s suppose your base asset is bitcoin and you are trading on the BTC-USD market: you may want to sell bitcoin when bitcoin price is falling to buy back a larger quantity of bitcoin for the same dollars, as you will be buying at a lower price.

With all that in mind, let’s assume you have a few strategies ready.

When do you start trading?

How do you know which strategy to use?

Stage 1: Trigger

Those two questions lead you straight into Stage 1 of your strategy and point to the first characteristic that needs to be present in it: the rules or conditions to trigger on the strategy.

Triggering Strategies

I call this particular set of rules a situation, in the sense that you are trying to determine what is going on with the market and if the situation is right to use a certain strategy.

Put in other words, you define situations in which you wish to use a certain strategy and each situation is described as a set of conditions that need to be met for you to consider starting to use the said strategy.

When the conditions for any of the situations that would trigger a strategy are met, I call this a trigger on event, meaning the event activates the strategy.

Now, what does that mean?

I’m not yet discussing taking positions, so it doesn’t mean that you should buy or sell something.

A trigger on event signals an ideal time to activate the strategy and look for the opportunity of taking a position.

Now let’s assume it is the ideal time to trigger your strategy, how do you next decide when to take a position or not?

To take a position, you will too define situations.

In this case, when the conditions that define a situation are met, this marks the take position event, that is, the moment to enter the trade.

Are you starting to see the pattern?

Your strategy is guided by predefined conditions that — when met — define situations that determine that a certain event will take place.

Now, what happens if the take position conditions are not met?

This leads us to understand that, just like you had a set of rules to determine when a situation seems appropriate, thus triggering on a specific strategy, you should also be able to analyze when the market has shifted out of those conditions — therefore cancelling the potential for taking a position — so that the strategy can eventually be triggered off.

Why is it important to trigger off a strategy?

It was established that while a strategy is on, you need to pay close attention to it and constantly evaluate the conditions for entering a trade. Triggering off the strategy allows freeing up those resources (your attention) and going back to doing something else.

Size Definition, Capital Request & Allocation

Before taking a position, it will be necessary to define the amount of base asset that you are going to risk in the trade — what I call the size of the position — which points back to one important concept I touched on before: capital.

It was established that — overall — you have a certain amount of capital to trade with and that you will need to manage. It was also established that you are most likely going to work with several strategies.

Do you see where I’m going with this?

This is when you start managing your capital.

Because you are working with several strategies, you need to decide how to allocate portions of that capital to each strategy. And — again — this is an integral part of the investment planning decisions that you will need to make and that are out of the scope of this article.

Suffice to say that capital allocation is part of your overall capital management and diversification plan, and a subject worthy of its a full level in the framework which may be covered in a follow-up piece later on.

Notice how the Stage 1 diagram above makes a clear differentiation between Size Definition and Capital Request & Allocation.

This is because each of those concepts is completely independent of each other at a conceptual level, and because in larger organizations, different people may take responsibility for each of them or co-participate in the process.

Take Position

I explained situations with their set of conditions when discussing trigger on and trigger off events that activate and deactivate strategies.

The same concept of situations with conditions apply when you are looking to take a position.

When setting up your strategy, you will describe situations, each defined by a set of rules or conditions that — when met — indicate that the moment is ripe for taking a position. I call this the take position event.

Taking a position refers to the act of entering a trade, that is, placing the orders at the exchange. These actions are taken in the next stage, during execution.

Quick Recap

Stage 1 is about monitoring the market and identifying when the conditions that define certain situations are met, triggering on one of your strategies.

You may see this as an early signal that tells you an opportunity may emerge soon.

The conditions that define the situation for actually taking a position may be seen as the final confirmation: the signal that determines that the time for entering a trade is as good as it gets.

I will give you a quick example…

Let’s say you are trading the BTC-USD market during the long crypto-winter. Your base asset is BTC, thus, you come up with a trend-following strategy based on the Bollinger bands indicator.

Your goal is to accumulate bitcoin selling BTC as the price starts dropping and re-buying BTC at a lower price when the price stabilizes.

One of the situations you wish to identify to trigger on the strategy is, for instance, when you detect what you may call an Incipient down-trend (or to be clear, a situation where a down-trend is developing).

How would you describe the Incipient down-trend situation with a specific set of conditions?

Well… you may come up with something like this:

Condition 1: The percentage bandwidth moving average of the Bollinger bands is going down…

Condition 2: The percentage bandwidth is smaller than the previous for two consecutive periods (2 candles)…

Condition 3: The minimum candle value is less than the previous minimum for two consecutive periods…

The framework dictates that when those three conditions are met at any moment in time, the strategy is triggered on.

So you keep looking and waiting for the final confirmation to take a position that is also defined by a situation embodied by its own set of conditions. You will probably want to give the situation a significant name, such as Down-trend entry signal.

The new set of conditions may look like the following:

Condition 1: The percentage bandwidth is smaller than the previous for the third consecutive period (3 candles)…

Condition 2: The minimum candle value is less than the lower Bollinger band for the last two periods (2 candles)…

That’s it! The conditions are met and you are finally ready to take the position.

So, what’s next?

Stage 2: Open

You have decided when is a good time to take a position. Good.

However, to complete the trade — that is, to buy back the base asset — you also need to define the rules to exit the position, or what I call the take profit and stop formulas.

Initial Take Profit & Stop

As per the definition of a trade, the main rule is minimizing the amount of the potential loss and — if possible — the goal is completing the trade at a profit, that is, ending up with a higher amount of your base asset.

In that sense, the next step is defining two separate rule-sets for exiting the position: take profit and stop. These formulas will allow us to do just that: take the profit when the trade hits a target or stop and exit the position in case things are not going as expected.

These rule-sets are most likely expressed as mathematical formulas.

The simplest approach is fixing a constant value as a percentage of the price at the time of the take position event.

For instance, let’s say you bought for 10 expecting the price to go up, and your profit target for the trade is a 20% win. Then your take profit would be at 10 + 20% = 12.

That would be a constant value for your take profit.

Then, let’s say you are willing to lose up to 2% of the capital in the trade if the market moves in the wrong direction; then your stop would be fixed at 10–2% = 9.8.

There certainly are many considerations as of how to set these two formulas, and several variables like market volatility, your risk profile, quality of the signal, long-term targets and so on will be part of the criterion you will want to consider. However, such considerations are beyond the scope of this article.

That said, it is important to note that setting constant values for take profit and stop is certainly a simplistic approach and that a lot more efficiency can be obtained with more dynamic formulas.

Such formulas may take into consideration the actual price movement, momentum, and as many indicators as you may wish to factor in the analysis.

Execution

If Stage 1 was mostly about monitoring the market, Stage 2 is about execution: you have identified that the moment is right to take a position, now it’s time to go and do it.

Why would you want to think of this as a two-stage process?

Isn’t placing an order at the exchange a pretty straightforward operation anyway?

Well… it may or may not be.

For starters, there are further decisions to be made: are you placing a market order or a limit order?

Moreover, the complexity of the execution depends on several factors, the most relevant being the size of the trade and the liquidity of the market.

Imagine placing a limit order to buy 1,000 BTC in a second-tier exchange…

The order would probably take some time to fill, get partially filled or not get filled at all, right?

Also, placing such a big order in the book may affect the market and substantially affect the price, which is undesirable.

Large orders need to be fragmented, sometimes even across different exchanges. Also, the position may be taken at different prices, or along a certain period.

However, because I’m introducing you to the Level One of the framework, for the time being, I will assume your orders will be rather small, in the order of magnitude that your exchange of choice can handle fine in a single order. The aforementioned tactics are the subject of a higher level of the framework which I may cover in future articles.

As you may now see, there are considerations to be made at the time of execution, and the task itself is quite different from monitoring the market, hence the view of the two as belonging to separate stages.

Stage 3: Manage

As hinted earlier, what you have read so far is the basis of the framework to develop your trading system.

As you may have noticed, a trading system corresponds to a lower level logic concerning the strategic aspects of trading. The system serves to structure the processes and methods that you will use to implement your trading strategies.

What follows are considerations that aim to increase the efficiency of your system.

In Stages 1 and 2, I described the fundamental components of the take position, take profit and stop events of a trade. What I haven’t covered so far are the underlying opportunities to manage the trade while you have an open position.

The term trade management implies that the rules set forth for the take profit and stop don’t need to be static.

I already discussed how setting the take profit and stop with dynamic formulas that take into consideration several relevant parameters such as current price or other indicators is preferred over the simplistic approach of setting a constant value considering the price at the take position event only.

The concept of managing a trade goes even further.

It means that the formulas to determine the take profit and stop may change as the trade develops.

The key point to take home is that there is a development or evolution attached to a trade. A trade is not an instantaneous event. It matures over time.

Then, how do you manage the trade?

What could happen that would make you want to change your take profit and stop formulas?

How do you determine when to change them?

Well… let’s start with stating the obvious: the development of the trade is analyzed through the same lens you have been using throughout the previous steps, meaning that you keep looking at the state of the market in relation to any number of indicators you wish to analyze, in an attempt to predict what may happen next.

But, most importantly, you analyze the market with a focus in your current targets, embodied by the originally defined take profit and stop.

To make this clearer, let’s remember the main reason why you want to manage the trade: to optimize the outcome.

Therefore, the typical situation in which you may want to change your original take profit and stop formulas is when the trade seems to be going well in your favor. That is, the market is moving in the expected direction and you seem to be making a profit.

Does this sound counter-intuitive?

Why would you want to change anything at all if things are going according to your expectations?

First of all, as long as the position is open, you haven’t accrued the profits!

Even if you seem to be winning, the market may reverse before hitting the take profit and may go all the way back to your stop.

In such case, if you were playing by the book of Stage 2 (with initial take profit and stop), you would end up with a loss even though you were temporarily winning at some point.

Under the Stage 3 paradigm, you would be interested in moving your stop as the price moves in the expected direction in such a way that even if the market reverses before hitting the take profit, you would end up with a smaller loss, with zero loss or even with a profit, depending on how much you manage to move the stop.

A second potential scenario is that the market moves in the desired direction and does not reverse.

In such a case, if you did nothing to manage the trade, you would hit the original take profit.

Good, right?

Now, what if the market keeps going way beyond the initial take profit?

Indeed, you would have missed a good opportunity to surf a big market move and make a much larger profit than originally expected.

The conclusion is that it may be in your best interest to manage both stops and take profit, moving them in the direction of the trade as the market moves, allowing some leeway for a larger profit than expected and at the same time cutting the potential for a loss.

Remember, greed is not the point of managing the trade; the point is optimization. You need to be careful not to increase the risk as you move the take profit, and make sure you are always tightening your stop at the same time too. In fact, the best practice is to move only part of your take profit, but again, the specifics of the tactics are beyond the scope of this article.

How does all this management translate in the framework?

The management of the trade is handled in phases.

Actually, the management of take profit and stop — while correlated — is done independently of each other, therefore, each concept has its own set of phases.


Changes to take profit and stop formulas respond to the same kind of logic you used to set the original values. When a situation defined by a set of conditions is met, the event indicates that take profit or stop formulas shall be changed. At the moment those predefined conditions are met, you enter the next phase. Keep in mind that the trade is in constant development, so there may be as many phases as you deem appropriate for your particular strategy.

In the animated image above, you may see chart notations indicating changes of phases on take profit (green) and stop (red). Horizontal red lines represent a dynamic stop at each candle interval while horizontal green lines represent a dynamic take profit.

The idea of having different phases comes from the notion that big market moves tend to provide clues as of what may come up next.

For instance, rallies may accelerate as more traders join the move. Recognizable patterns may emerge. Signs of exhaustion may be identified.

All of these considerations should feed the dynamic analysis performed as the trade develops, and may be contrasted with the predefined conditions that may push take profit or stop further, entering one phase after the next.

Stage 4: Close

Closing Execution

The Closing Stage has very similar implications to what I explained in the Open Stage in regards to execution.

While it is true that the trade management process takes care of making the decisions as of when to close the position by managing the take profit and stop, the actual execution of the exit may require further considerations when dealing with substantial amounts of capital.

It is for that reason that I propose to understand execution as a separate stage, while it may not be required in practical terms if you are trading a small capital. If that is the case, then your trade management includes the actual execution and you don’t need to consider any other variables.

As hinted earlier, I may review more complex execution tactics in a separate article later on.

Record Keeping

While it is sometimes disregarded as a boring task, record keeping is a fundamental part of the process and should be implemented in your trading system.

It doesn’t require much analysis to conclude that being able to track the results of each of your trades will become a fundamental piece of information that should help you fine-tune your strategies in the future.

Remember that markets evolve and strategies perform well for limited periods. Therefore, you should implement a procedure that will evaluate the efficiency of your strategies over time.

Such procedures are out of the scope of this piece and I may cover them in a future article. For the time being, just make sure you take note of each of your trades, with at least the basic information, such as date of opening, reasons for entering the trade (conditions met to take the position), take position price, initial and last take profit and stop, return on the trade (%), profit & loss (expressed in your base currency) and duration of the trade.

Further Levels

So far, I covered the basic framework — what I call Level One — analyzing the four stages of a trading strategy.

Needless to say, there is a lot more depth on the subject of trading systems.

I would argue that if you manage to implement the framework up to this Level One, you will have built a solid base for becoming a successful trader.

That said, it is what comes after Level One what will put you higher in the food chain. For instance, two of the most relevant subjects left out of the scope of this piece are capital allocation and risk management.

I might get on to that later on with a follow-up piece, so stay tuned!

In the meantime, it’s up to you to get up to speed with a solid foundation for your trading system…

My Implementation

I'm a co-founder of the Superalgos Project, an open-source project developing and freely distributing trading tools, and building a Collective Trading Intelligence.

The framework proposed in this article has been implemented as the Superalgos Protocol, a trading protocol that enables the standardization of the description of trading strategies.

Standardizing how trading strategies are defined enabled the development of Superalgos, a piece of open-source software that helps traders fully automate their work.

The Superalgos Platform is a client app running on user's machines, removing all trust requirements (no need to trust a third party with funds, API Keys or strategies).

Traders may build strategies in a visual setting (no coding required) and test their performance in real-time through a simulation engine with historical (backtesting) and up-to-date (paper-trading) market data. Once happy with the simulation output, traders may deploy their strategies as fully automated trading bots, and trade live.

Join our Telegram to engage with other users and the developers behind the project.

Acknowledgment: Thanks to Andreja Cobeljic for his technical review/editing.

Disclaimer: I am not a financial advisor and this is not financial advice. I share strategies and my own trading experiences as a means to disseminate knowledge. You are responsible for whatever you choose to do with the information I share.

Disclosure: The author is a core team member of the Superalgos Project.

Featured Image Credit: © WHYFRAME, shutterstock.com