Pumps, dumps, and liquidation. Welcome to Bitcoin. Trading Bitcoin has once again become the . The possibility of actually off that $1,000 candlestick that shot out of nowhere is very alluring. newest , hottest thing all the investors are trading profiting However, , and getting lost in the market is something all-too-familiar for many of us. it's not easy to predict these fluctuations For these reasons, today I will be showing you . Prepare to cut out the emotion, and bring in the algorithms. how to program a Bitcoin trading bot in less than 10 minutes Trade at your own risk. Before any programming, we must first find a to use to play the market and model the bot after. For this article, I chose to use a simple . viable strategy volume-based trading strategy The strategy is simple: . when volume peaks, there is more interest in the market, and this means the trend with the volume peak will probably continue in the future In the image below, three distinct peaks in volume are circled. The arrows represent that . even if the peak in volume is followed by a dump, it will usually rise higher than current market value in the near future, as the trend is still upwards Now that we have a basic strategy in mind for this bot, we can begin to program! Perhaps the most basic language to write our bot in will be , TradingView's language for writing indicators and scripts. PineScript To begin programming, (shown below). navigate to the PineScript editor in your TradingView account Now, open strategy script. New > Blank At this point, your editor should look something similar to this: //@ = strategy( , overlay= ) longCondition = crossover(sma( , ), sma( , )) (longCondition) strategy.entry( , strategy. ) shortCondition = crossunder(sma( , ), sma( , )) (shortCondition) strategy.entry( , strategy. ) version 4 "My Strategy" true close 14 close 28 if "My Long Entry Id" long close 14 close 28 if "My Short Entry Id" short To clean it up a bit, I'm going to delete all lines except the first two. You can now begin to program. Firstly, to find a " " in Bitcoin's volume based on the volumes of surrounding candlesticks. To pull values for volume, . we must derive an algorithmic method peak insert these lines into your editor volumeOne = volumeTwo = volumeThree = lastVolume = averageVolume = (volumeOne+volumeTwo+volumeThree)/ volume [1] volume [2] volume [3] volume [0] 3 Essentially, . These values will be necessary for our next step. To determine whether volume has peaked at a given candlestick, I will be using a simple method of determining . for every candlestick on our chart, these lines will pull the 3 volumes of the 3 candlesticks before it and then calculate their average whether the current bar's volume is 5 times greater than that of the average of the 3 bars before it Note: in a more advanced bot, you could calculate the standard deviation or IQR of the data to determine peaks. This calculation will be entered as as shown below, either true to long, true to short, or false to not long, false to not short. two boolean values longCondition = lastVolume > averageVolume * close[ ] > open[ ] shortCondition = lastVolume > averageVolume * close[ ] < open[ ] 5 and 0 0 5 and 0 0 Having written our long and short conditions, . This can be done as shown below. the buy and sell orders may finally be added to our script Note: limit orders are being used because most exchanges charge high taker fees, and our bot aims to avoid those, as it trades at a high frequency. strategy. ("long", , = - , = longCondition) strategy. ("short", , = + , = shortCondition) order true limit close 1 when order false limit close 1 when Finally, and is functional as is. However, there is one more thing we must add to it: . our Bitcoin bot has been finished, technically stop-loss and take-profit orders. Stop-loss orders prevent bad trades from losing too much money and take-profit orders allow us to get out with out profit before the price could take a hit To implement this, we will add two values that the user may input: . The orders will be written as shown below, and on the next image, the two user-entered variables are programmed at the top. percentage change to cause a stop-loss, and percentage change to cause a take-profit strategy. ( , , profit = abs(close*profit - close), loss = abs(close*stopLoss - close)) strategy. ( , , profit = abs(close*profit - close), loss = abs(close*stopLoss - close)) exit "exit" "long" exit "exit" "short" And with that, Here is what you're script should look like now: you've finished programming your Bitcoin trading bot! strategy( ) stopLoss = input( = , defval= ) profit = input( = , defval= ) volumeOne = [ ] volumeTwo = [ ] volumeThree = [ ] volumeFour = [ ] volumeFive = [ ] lastVolume = [ ] averageVolume = (volumeOne+volumeTwo+volumeThree)/ (lastVolume/ , color= (averageVolume/ , color = longCondition = lastVolume > averageVolume * [ ] > [ ] shortCondition = lastVolume > averageVolume * [ ] < [ ] strategy.order( , true, limit = - , when = longCondition) strategy.exit( , , profit = ( *profit - ), loss = ( *stopLoss - )) strategy.order( , false, limit = + , when = shortCondition) strategy.exit( , , profit = ( *profit - ), loss = ( *stopLoss - )) //@version=4 "Volume Momentum" title "Stop loss" 0.9 title "Profit gain" 1.2 volume 3 volume 1 volume 2 volume 4 volume 5 volume 0 3 plot 10000 #00ffaa) plot 10000 #000000) 5 and close 0 open 0 5 and close 0 open 0 "long" close 1 "exit" "long" abs close close abs close close "short" close 1 "exit" "short" abs close close abs close close And here is TradingView's most recent report on the bot's performance (taken from the 1-minute chart): In the future, we can add filters to make the bot pickier in its trades and thus more accurate. In an account with $100, trading $10 at a time, the bot profited near 10% in a week! And that's it! Congrats!