0% found this document useful (0 votes)
128 views5 pages

Hamid Jazayeriy Spa Bot Smart Price Action Trading Bot

hamid-jazayeriy-spa-bot-smart-price-action-trading-bot

Uploaded by

amrik51072
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views5 pages

Hamid Jazayeriy Spa Bot Smart Price Action Trading Bot

hamid-jazayeriy-spa-bot-smart-price-action-trading-bot

Uploaded by

amrik51072
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

2021 12th International Conference on Information and Knowledge Technology (IKT)

SPA Bot: Smart Price-Action Trading Bot for


Cryptocurrency Market
Hamid Jazayeriy* Mohammad Daryani
Department of Computer Engineering Department of Computer Engineering
Babol Noshivani University of Technoloy Babol Noshivani University of Technoloy
Babol, Iran Babol, Iran
JHamid@nit.ac.ir 1mo.daryani@gmail.com

Abstract— Cryptocurrencies can be traded 24 hours a day II. RELATED WORK


over the globe where crypto market never stop working. This
market is known for being highly volatile and prices fluctuate Although the topic of automated trading in crypto market
2021 12th International Conference on Information and Knowledge Technology (IKT) | 978-1-6654-0849-3/21/$31.00 ©2021 IEEE | DOI: 10.1109/IKT54664.2021.9685662

rigorously in a minute. Even seasoned traders are unable to is an emergent field of study, there are a few valuable studies
react quickly enough to this volatility. This is why automated that will be reviewed in this section.
trading bots get into the picture. On the other hand, crypto
Traditional trading systems can be developed based on
trading bots need more improvement to mimic expert traders’
some well-known techniques which are popular among
activities. In this paper, we propose a bot which is able to buy
and sell using a dynamic price-action technique. Experimental seasoned traders [4]. These techniques are usually based on
results from back-testing show that the proposed bot effectively some statistical models. The first generation of trading bots
utilized the classical price-action technique for trading in have been developed based on these models. The results from
cryptocurrency markets. this bots showed that they are not trustworthy in all situations
and may cause some loses. The second generation of trading
Keywords— cryptocurrency, automated trading, Bot, price- bots tries to utilize trading algorithms by using artificial
action, active true range intelligence techniques.
I. INTRODUCTION Reinforcement learning (RL) is one of powerful AI tools
where an agent (say bot) can learn from its actions [5].
Blockchain technology brings new business opportunities Rewards and punishments help to find the best reaction to the
while the market capital of its related industries are growing environment. There are some tested RL-based agents that can
dramatically in recent years. Cryptocurrencies are getting be adapted in any environment. In [6], different RL-based
more popular and many individuals and companies invest in agents (such as A1C, A2C, APPO, IMPALA and PPO) have
this 24×7 market. However, due to the high volatility in crypto been used for automated trading on BTC, BAT and NANO
market, trading is a very risky profession and many naïve markets. They concluded that A2C was the best reinforcement
traders lose their money. In addition, seasoned traders cannot learning algorithm for automated trading. Moreover, they
work 24 hours a day, and they miss some trading opportunities found that cryptocurrencies with low capitalization (like
[1]. NANO) are not suitable for algorithmic trading.
Automated crypto trading bots are set of computer Unfortunately, they found that the buy and hold strategy,
programs developed to automate pre-defined trading despite its simplicity, outperforms all RL-based trading
strategies by sending sell/buy orders to exchanges on behalf agents.
of their owners. They never miss the trading opportunities in Prediction of cryptocurrencies in low time-frames can help
24 hours. Moreover, they never succumb to fear and greed, or bots for scalping or option trading. In [7], an artificial neural
any other human emotions. Both advanced traders and network (ANN) based machine proposed for algorithmic
beginners can use automated trading bots based on their needs. trading in binary option markets. In binary options, bots can
The quality of trading bots depend on the way they utilize win a reward for correct prediction of the future price
artificial intelligence techniques to maximize the profit while movements or loss some money for wrong guess. The
minimizing the risk [2]. Smart bots use artificial intelligence researchers, designed an algorithm for option-trading in 5-min
to analyze and interpret market statistics before making time frame where a bot should predict the next 5-min price as
decisions. up or down binary. They showed that the best overall model
was a deep-MLP with 54% accuracy for predicting of the next
In general, artificial intelligence techniques can help up or down classification problem in BTC market.
trading bots to improve trading strategies, finding best setup Unfortunately, the accuracy of 54% in not good enough for
for technical functions, and risk management [3]. In this study, option trading in 5-min time frame.
we propose an automated trading bot based on the price-action
technique. Price-action is a very popular trading technique In short, automated trading in crypto market is very young
among seasoned traders. and needs more effort to reach high quality bots [8].
The rest of the paper is organized as follows: the next
section reviews related works. Then, the proposed SPA bot is
presented in section III, followed by its evaluation. Finally, III. PROPOSED METHOD
section V presents our conclusions. To develop an automated trading bot, the following
component should be considered: capital management, risk
management and technical analysis [9], [10]. Each of these

978-1-6654-0849-3/21/$31.00 ©2021 IEEE


178
Authorized licensed use limited to: ANNA UNIVERSITY. Downloaded on February 05,2024 at 08:41:57 UTC from IEEE Xplore. Restrictions apply.
components can be improved by using artificial intelligence
accordingly.

Fig 2. Dynamic upper and lower boundaries in smart price action.

Fig 1. Elements of a generic trading bot.


Each boundary in Fig.2 is presented by an area surrounded by
two lines. One of them presents the inner margin (lower case
Technical analysis usually helps to answer two crucial letters: h, l) and the other one presents the outer border of the
questions: when to enter the market by send buy/sell orders? area (upper case letters: H, L).
And, when to close the active orders? In this study we propose a dynamic boundaries based on the
Traditional algorithms for trading usually apply fixed concept of active true range. The active swing (movement)
parameter in all time-frames. Finding the best performance of can be calculated based on high and low values in Japanese
an algorithm needs artificial intelligence techniques to adapt candle stick.
its parameters in each time-frame. A typical Japanese candle stick is presented by four points:
In this study, a price-action based technique is proposed and low, high, open and close. Fig. 3 shows a typical Japanese
utilized for automated trading by using artificial intelligence. candle stick.
Therefore, the main focus of this study is technical analysis.
The proposed technique is named smart price-action (SPA).
The rest of this section is illustrating the steps in the proposed
price-action algorithm (SPA).
A. Proposed Price-Action
Algorithm 1 describes the steps of a generic price action.
Finding a proper binderies for price movement is focal point
of price-action technique.

Algorithm 1. Price-action
1 Find upper and lower price boundaries
2 Select an active boundary
3 Wait for rejection or breakout
4 Check for confirmation Fig 3. Japanese candle stick.
5 Enter a position
we have proposed a dynamic areas based on the concept
The first three steps are related to the upper and lower of active true range (ATR) to present upper and lower
boundaries. boundaries needed for price-action. Active true range (ATR),
Price in price-action is normally limited between to is the average of swing values in the recent market depth (say
horizontal pivots. The upper pivot is called resistance and the ). In this study, and are used to represent the average and
standard deviation of swing values, respectively.

1
lower one is call support.

= = ℎ ℎ −
Fig. 1 shows a sample boundaries. If price touches upper
boundary, then two scenarios is considered: (1)
(i) Rejection and return into the moving channel. In this case,

1
a traders can get a sell position.

= | ℎ ℎ − − |
(ii) Breakout the channel. In this case, price trying to reach a
new higher high and it gives an opportunity to get a buy (2)

The upper boundary of the current price is presented by ℎ


position.

and values. Where ℎ and are the high inner and the high
Similarly, a buy and sell opportunity may be occurred when
price tested the lower boundary.
outer boundaries, respectively.

ℎ=ℎ ℎ , − !. (3)

= #$% ℎ ℎ ℎ ℎ, , ℎ + #$' (4)

179
Authorized licensed use limited to: ANNA UNIVERSITY. Downloaded on February 05,2024 at 08:41:57 UTC from IEEE Xplore. Restrictions apply.
The #$'
#$' = + (.
value is defined as follows:
(5)

presented by and ) values. Where and ) are the low inner


Similarly, the lower boundary of the current price is

and the low outer boundaries, respectively.

= , + !. (6)

)=# , , − #$'
In the above equations there are two parameters (!, ()
(7)

which help to utilize the dynamic boundaries using soft-


computing techniques.
Changing on the price value, may change the low and high
values of the current candle, and ATR consequently.
Fig 5. A breakout from outter border (L) shows a sell (red column)
Therefore, the boundaries may change dynamically. opportunity.
After finding the dynamic boundaries using active true
range. The proposed algorithm waits for touching the
boundaries by price movement. The following condition will Next step in the proposed algorithm is the decision
confirmation. A simple yet effective technique for
<ℎ $ , - >ℎ ' / moving average of the given depth d based on the source ( ' )
be examined for sell and buy opportunities.
confirmation is using moving average. Equation (10) show
= * '
<) $ , - >) 0' $1 2
(8)
1
values.
4
#$ , = '
,
(10)
> $ , - < ' /
023 = * '
> $ , - < 0' $1 2 or hl2, where ℎ 3 ℎ ℎ+ +
(9) The source value can be one of the followings: close, hlc3,
6
ℎ2 ℎ ℎ+
and
, respectively.
Fig. 4 demonstrates the performance of the proposed To utilize the algorithm we need to choose one of these
algorithm on VET/USDT spot market in 5 min time frame in sources as well as choosing the optimized depth d value.
Binance when rejection occurs.
Confirmation for buy and sell decisions can be made by

> #$ , 023
using the following conditions.

8 '#$ = *
< #$ ,
(11)

Fig. 6 shows the effect of confirmation using moving


average on VET/USDT spot market in 4H time frame in

be crossed by a short moving average (, = 5).


Binance. The candle which shows buy or sell decision should

Fig 4. Sell (red columns) and buy (green columns) in inner channel
when rejection occurs..

Fig. 5 demonstrates the performance of the proposed


algorithm on VET/USDT spot market in 1 min time frame in
Binance when breakout occurs from L border where a sell
order can be considered. When breakout occurs a new l and L
border will get into the picture.
Having sell/buy opportunity is not enough to enter a
position. In other word, to increase the hit rate of the algorithm
a confirmation is needed.

Fig 6. The effect of confirmation using moving average (, = 5).

180
Authorized licensed use limited to: ANNA UNIVERSITY. Downloaded on February 05,2024 at 08:41:57 UTC from IEEE Xplore. Restrictions apply.
+ 2∆ 023
$1 J' 8 = *
Having long moving averages may reduce the chance of

− 2∆
trade opportunities while short moving averages may lead the (14)
algorithm to a false detection (fake breakouts or rejections).
B. Utilizing the SPA using artificial intelligence

parameters: , ! , ( , , and ' . In this study, a genetic and take-profit, we have proposed a dynamic value, ∆, based
The quality of the proposed SPA algorithm depends on its Instead of using a fix value (or percentage) for stop-loss

candles. Equation (12) helps to find ∆, and set stop-loss and


algorithm (GA) is used to find the optimal values while back- on the average changes (price fluctuation) in the recent 200
testing the market. Each chromosome defined as set of 5 genes
containing the following parameters: take-profit dynamically. Then, (13) and (14) are used to
calculate the stop-loss and take-profit for buy and sell

!: coefficient in (3) and (6)


: depth of the market for calculating boundaries accordingly.

(: coefficient in (5) reward ratio (∆, 2∆) to explore the win rate of the proposed
In this study, we have used a fixed value for risk and

,: length of confirmation moving average


SPA algorithm. This setting is taken for the simplicity of the

' : data source for moving average


ruin experiments and can be considered as a drawback of this
study.

# , ℎ -' 8
The search space of this optimization problem is very The win rate can be calculated by the following formula:

=
$ 2#0 ' 8 '$,
large. To reduce the search space, the domain of each
parameter is limited by Fibonacci numbers and coefficients as (15)

∈ ;13, 21, 34, 55, 89, 144, 233, 377, 610, 987,1597B
follows:
Together with win rate, the total number of trades should

! ∈ ;1, 2, 3, 5, 8, 11B
also be considered.

( ∈ ;0.38, 0.5, 0.61, 1, 1.44, 1.61, 2.61B


Table 1 shows the optimum parameter values for the
proposed SPA algorithm. Each time frame needs to be setup

, ∈ ; 2, 3, 5, 8, 13B
using a set of different parameters’ value to show its best

' ∈ ; , ℎ 2, ℎ 3B
performance.
Table 1. Parameter setting using evolutionary computing.

The best value for this parameters should be finded by GA. Parameters

α ( , '
In the next section, the experimental setup and results of the Time Frame
proposed method are explained.
1m 377 5 1.61 8 hlc3
IV. EVALUATION
5m 233 5 1.44 5 hlc3
To evaluate the quality of the proposed SPA algorithm, a
30m 144 5 1 3 close
trading setup needed. Accordingly, the BTCUSDT and
VETUSDT are selected as two cryptocurrency markets for 1H 89 3 1 2 close
evaluation the SPA. Moreover, back-testing are taken in the 4H 55 3 0.5 2 close
last two years data provided in TradingView’s website. At 1D 34 2 0.5 2 close
first, the parameters of the algorithm are calibrated, and then
the win rate and the frequency of the trades in each time frame
are evaluated. The win rate of the trading algorithm is reported in Table
The total profit of the investment depends on liquidity 2. As it can be seen, in lower time frames the algorithm has
management as well as SPA algorithm and the risk lower win rate and the maximum win rate is reported in 1D
management. The main goal of this study the evaluation of the time frame. On the other hand, the average number of trades
proposed SPA algorithm. Therefore, the concept of the per day in 1D is very low while the lower time frames have
liquidity management is excluded from this study. much more frequent trades. Table 3 reports the average
number of trades per day for each time frame.
The quality of the proposed algorithm is related to its
parameters’ values. To find the best parameter setting we need Table 2. Average win rate of the proposed SPA algorithm.
to run algorithm and find the win rate of the submitted orders. Win rate (%)

M N OP
By considering a risk to reward ratio of 1:2, the following Time Frame
formula is used to find the amount of stop-loss and take-profit
in each time frame:
FF
1
1m 52 54

∆= D ℎ ℎ − / - G×
200
(12) 5m 63 61

−∆ 023
30m 70 69

I -) = *
1H 73 74

+∆
(13) 4H 78 79
1D 81 82

181
Authorized licensed use limited to: ANNA UNIVERSITY. Downloaded on February 05,2024 at 08:41:57 UTC from IEEE Xplore. Restrictions apply.
Tables (2) and (3) show that high trading frequency would [3] S. Saksonova and I. Kuzmina-Merlino,
not guarantee the maximum win rate. To reach the best “Cryptocurrency as an investment instrument in a
performance for SPA algorithm, we need to find the best time modern financial market,” Вестник Санкт-
frame where the maximum profit is available. Петербургского университета. Экономика, vol.
Table 3. Number of trades per day.
35, no. 2, 2019.

QRS
[4] B. Huang, Y. Huan, L. Da Xu, L. Zheng, and Z. Zou,

M N OP
Time Frame “Automated trading systems statistical and machine
learning methods and hardware implementation: a
survey,” Enterp. Inf. Syst., vol. 13, no. 1, pp. 132–144,
1m 112 117
2019.
5m 21.42 22.05
[5] M. A. H. Dempster and V. Leemans, “An automated
30m 6.25 6.77
FX trading system using adaptive reinforcement
1H 1.62 1.73 learning,” Expert Syst. Appl., vol. 30, no. 3, pp. 543–
4H 0.45 0.48 552, 2006.
1D 0.085 0.09 [6] S. W. H. Akkerman, “Automatically trading small
market capitalization cryptocurrencies using
reinforcement learning,” 2021.
As it mentioned, we have used a fixed risk to reward ration
to evaluate the win rate of proposed algorithm. Preliminary [7] A. Ibrahim, R. Kashef, and L. Corrigan, “Predicting
observations of the running algorithm in higher time frames market movement direction for bitcoin: A comparison
show that the reward ratio can be considered much bigger than of time series modeling methods,” Comput. Electr.
what assumed in this study. Eng., vol. 89, p. 106905, 2021.
V. CONCLUSION [8] A. Bigiotti and A. Navarra, “Optimizing automated
In this study, the smart price-action (SPA) algorithm is trading systems,” in The 2018 International
proposed for automated trading in the cryptocurrency market. Conference on Digital Science, 2018, pp. 254–261.
This algorithm uses dynamic boundaries to keep track of the [9] C. Y. Kim and K. Lee, “Risk management to
price movement and take a proper decisions (buy/sell) in the cryptocurrency exchange and investors guidelines to
market. To optimize the trading parameters, a genetic prevent potential threats,” in 2018 International
algorithm (GA) is used. The experimental results show that
Conference on Platform Technology and Service
the SPA has 81% win rate in daily (1D) time frame while the
(PlatCon), 2018, pp. 1–6.
chance of having a daily trade is less than 0.1. On the other
hand, the win rate for 1m time frame is about 50% and more [10] A. Mikhaylov, N. Sokolinskaya, and E. Lopatin,
than 100 trade situations may occur in this time frame. “Asset allocation in equity, fixed-income and
We have used Fibonacci numbers to reduce the search cryptocurrency on the base of individual risk
space for finding the optimum values of parameters in the sentiment,” Invest. Manag. \& Financ. Innov., vol. 16,
proposed algorithm. In the future, a more accurate and no. 2, p. 171, 2019.
comprehensive study is needed to find the parameters’
optimum value. Moreover, for the order confirmation, we
have used the moving average while it may be improved by
other technical indicators. Finally, finding a proper risk and
liquidity management that suited for the proposed SPA
algorithm can be an interesting field of study and practice.
Acknowledgement: This research work was partly
supported by the bitbotec.com.

VI. REFERENCES
[1] Y. Andrianto and Y. Diputra, “The effect of
cryptocurrency on investment portfolio effectiveness,”
J. Financ. Account., vol. 5, no. 6, pp. 229–238, 2017.
[2] I. U. Haq, A. Maneengam, S. Chupradit, W. Suksatan,
and C. Huo, “Economic Policy Uncertainty and
Cryptocurrency Market as a Risk Management
Avenue: A Systematic Review,” Risks, vol. 9, no. 9, p.
.
163, 2021.

182
Authorized licensed use limited to: ANNA UNIVERSITY. Downloaded on February 05,2024 at 08:41:57 UTC from IEEE Xplore. Restrictions apply.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy