This article is taken from Issue #8 of 21 Cryptos Magazine
Written by Beastlyorion (@beastlyorion)
When I started trading cryptocurrencies for the first time, I hadn’t the slightest clue what I was doing. It was a thrilling experience where I gambled all of my invested money around from one coin into another, in the hopes that one of them might pump hard as I watched seemingly every coin I didn’t own go to the moon. A while after joining, I had lost a significant amount of my starting investment, even while the market had been rising. I realized how inexperienced and prone to error I was, but I just knew that it had to be possible to outperform the market if only I could learn how.
I began to research the fundamentals of blockchain projects and how to trade using technical analysis, while I attempted to develop a trading strategy. I lowered my risk on each position, which enabled me to distance myself from my trades and reflect on my performance, allowing me to further advance my strategy. This stage of developing my own strategy and gaining an understanding of the markets resulted in a drastic improvement in my performance over time and significantly less drawdown during each bear market.
Eventually, however, I found that regardless of how in tune with the markets I was, I continued to fall prey to the limitations that I am subject to as a human. I came to the realization that becoming a better trader would mean that I would have to sacrifice a part of myself that I just wasn’t willing to give up: my emotions. I know it sounds a little cheesy, but the best way to gain an advantage over others in the market is to completely emotionally distance yourself from your trades. Unfortunately, it is very difficult (if not impossible) to do that without letting part of yourself go in the process.
“I am able to relax and focus on improving and expanding my bot’s functionality while it consistently makes trades utilizing the algorithm I’ve developed for it.”
This train of thought led me to an idea that I’ve been toying with for a long while now: an automated trading system, or bot (short for robot). If it is, in fact, possible to outperform the market using technical analysis, then theoretically it should be possible to outperform the market more successfully with an automated system. Moreover, if the biggest thing holding back traders from succeeding is their own emotions, then an obvious solution for them would be to develop a system free of emotion to trade in their place.
That’s exactly what I’ve been working on over the past few months. I am still testing my strategies, but so far I’ve found that they do work, and I am able to relax and focus on improving and expanding my bot’s functionality while it consistently makes trades utilizing the algorithm I’ve developed for it. Pulling from this experience, I want to shed some light on how I went about making my bot and provide a few steps to push those who are interested in making their own in the right direction.
I should preface this with a disclaimer: it is not easy to make a bot if you are not familiar with trading or programming. Making an automated trading system takes a lot of time and effort—your end product will be heavily reliant on your ability in those fields. Despite the challenge, I believe it is worth the effort to build your own bot if you are able. If you are successful, it could be immensely profitable.
There are two main components of building your own trading bot:
Develop the algorithm
Your bot needs an algorithm to decide when and how to trade. Even if you feel that you are not interested in programming a bot, this step can be immensely beneficial in advancing your existing trading strategies. A very successful strategy should remain confidential so that nobody else can take advantage of your work and render your algorithm useless.
Develop the bot
You will need to code your strategy into a program that is able to communicate with the exchange you want to trade on and perform actions, such as opening, managing, and closing trades based on incoming data from the exchange. This step requires some self-study on your part to be able to write and understand the program. If you are new to programming and are willing to put in the time and effort to learn, I recommend taking an online video course at Udemy. The courses are very affordable, and you can learn as much as any university student for under $20, given that you have the persistence and patience to complete the courses.
In the end, if trading doesn’t work out for you, you may qualify for a programming position in a corporate setting after working through a couple of these courses. If you are not up to the challenge of developing your own bot from scratch, you have a few options. There are open source and paid bot services that you can seek out and implement your own strategies with if you are interested, but make an effort to understand how they work, and ensure that they are not malicious before you attempt using them.
Developing the Algorithm
To develop your own algorithm, you will need a backtesting suite to test your algorithm’s performance over historical market data. I’ve found that Tradingview’s Pinescript and backtesting system handles this very well. If you are on Tradingview’s homepage (tradingview. com), you can browse through the different scripts that others have written underneath the “Scripts” drop-down. This will help give you an idea of the kinds of strategies that others are creating. Many of them are very complicated, but your strategies don’t have to be, especially when you are starting out. If you navigate to an interactive chart of your choice (if you’re new to tradingview, head here and click “Interactive Chart”), on the bar at the bottom of the window you can access the “Pinescript” tab. Click on that tab and it should open a very basic script:
This code is initializing a new study: “My Script” and then plots the close of every candle on the chart. If you click the “Add to Chart” button on the top right of that text window to the right of the save button, it will add your study to the chart so that you can see it in action. Now, if you click the “New” drop-down, and select “Blank Strategy Script”, it will open a slightly more complicated Pinescript example.
This example declares a condition on when to go long and a condition on when to go short. The conditions are dependant on the built-in moving average function that tradingview offers: sma(). Basically, it is saying that whenever the short period moving average passes over the long period moving average, it will open a long position, and whenever it passes under the long period moving average, it will reverse the position and open a short position.
If you click the “Add to Chart” button, you will be able to see this strategy in action. Tradingview will automatically switch tabs to the “Strategy Tester” tab, where you can analyze the strategy’s performance against the historical market data. Performance statistics will be visible in this window.
If you click back over to the pinescript tab, you can adjust the number of candle closes counted in each moving average and click save. Your strategy will update and you will be able to view the effects of your updates on the performance of your strategy under the strategy tester tab.
“If you manage to create a successful algorithm, you might find that using it in combination with fundamental data that you have collected may lead to a higher success rate in your trades.“
This is just a small sampling of the functionality that is offered in Tradingview’s Pinescript. You’ll want to visit https://www.tradingview. com/study-script-reference/ for the full reference documentation of Pinescript’s functionality which you can use to create much more powerful and in-depth algorithms. If you are seeking further guidance or inspiration, I recommend snooping through other people’s publicly shared scripts or searching for tutorial videos online to help push you in the right direction. I recommend experimenting with the common indicators that are built into Pinescript. A complete list of the inbuilt functions and indicators can be found in the reference documentation.
Developing a successful trading algorithm can be extremely beneficial as a trader, even if you are not interested in automating it. Algorithms perform more consistently and predictably than human traders. On the other hand, humans are able to adapt to particular situations and take in information that a bot might not be able to. If you manage to create a successful algorithm, you might find that using it in combination with fundamental data that you have collected may lead to a higher success rate in your trades.
Developing the bot
Once you have developed a strategy that you are satisfied with, the next step is to write it into a program and put it into action. There are a few stages to this:
- Write the logic to handle communications with the exchange you are trading on
- Testing the bot
- Free money (in theory…)
“If your bot is running successfully, you can sit back and relax while your bot hums away.”
This part is tricky because how you do it is completely up to you. As previously mentioned, if you are not familiar with how to program, you’ll want to learn to do that first. I recommended the courses on Udemy because they are generously priced and accessible for all to use. For those who do know how to program, some things you’ll probably want to look into are libraries (free-to-use collections of pre-programmed functionalities) that handle the calculations for the indicators your strategy uses, and the libraries that are provided to you by the bigger exchanges that make handling API calls insanely clean and easy.
When testing the bot, you’ll want to start off on a testnet or at least disable your bot’s ability to open trades until you know for certain that it is performing the way you are expecting it to. Once you are warmed up to the idea of the bot trading your money, you’ll want to start it off on a new live account with a small amount of money and increase its available funds as it continues to earn your trust. If you find that the algorithm is not performing within an acceptable profit margin when compared to your backtests, you’ll want to pause production until you discover the issue and fixed it. At this point, if your bot is running successfully, you can sit back and relax while your bot hums away. If you want, you can continue to develop its functionality, continue adjusting the algorithm to meet your needs, or you might choose to re-assimilate into the normie world while your bot handles your portfolio. Remember to check up on your bot’s performance regularly to ensure it keeps functioning properly. Otherwise, let the profits flow freely and enjoy life. I am excited to see what you guys can come up with. Good luck to you brave souls that attempt creating your own bot. As always, happy trading!
To read more articles on crypto investment subscribe to 21 Cryptos Magazine below. You can also see our other articles here.