Professional Documents
Culture Documents
ALGOGENE - A Trend Following Strategy Based On Volatility Approach
ALGOGENE - A Trend Following Strategy Based On Volatility Approach
ALGOGENE - A Trend Following Strategy Based On Volatility Approach
(/home)
Categories
A trend following strategy based on volatility approach
tony (https://algogene.com/community/post/61)
lam
Trading Strategy Economy & Market 19
(/community/searchPost?
page=1&category=Economy+%26+Market)
In this article, we will introduce a simple trend following strategy using a volatility approach.
How it work (/community/searchPost? 28
page=1&category=How+it+work)
page=1&category=Programming)
Volatility is used to reflect the magnitude of market fluctuation, and it is usually used to observe market
Quantitative Model 8
sentiment or predict market trends. In financial market, due to the behavior of "Market take the stairs up and the
elevator down", the volatility distribution is not symmetric. Therefore, it is necessary to distinguish upside and (/community/searchPost?
downside volatility. page=1&category=Quantitative+Model)
In this article, we take the opening price as the benchmark, the fluctuation above the opening price is defined as Trading Strategy 9
the upward volatility, otherwise it is the downward volatility. Under normal circumstances, the upward volatility (/community/searchPost?
is greater than the downward volatility when the market is in the upward trend, and vice versa in the downward
page=1&category=Trading+Strategy)
trend.
In above definition, the difference between upward and downward volatility is measured as:
哪裡可以查看algo運行情況?
(https://algogene.com/community/post/102)
difft := (Hight + Lowt ) / Opent - 2 22 1 0 2023-02-08
Based on a sliding window approach to collect the previous 250 closing price 166 1 5 2023-01-04
https://algogene.com/community/post/61 1/7
2023/2/10 15:49 ALGOGENE | A trend following strategy based on volatility approach
We use the API function getHistoricalBar to collect historical observations. Then, we use the 'pandas' library to
calculate the simple moving average.
Now, we update the system's function 'on_marketdatafeed' for order open logic. We will use the API function
'getSystemOrders()' to get our outstanding order inventory. (refer to line #20 - #33 below)
https://algogene.com/community/post/61 2/7
2023/2/10 15:49 ALGOGENE | A trend following strategy based on volatility approach
https://algogene.com/community/post/61 3/7
2023/2/10 15:49 ALGOGENE | A trend following strategy based on volatility approach
https://algogene.com/community/post/61 4/7
2023/2/10 15:49 ALGOGENE | A trend following strategy based on volatility approach
Results
Now, we are prepared to backtest this strategy.
Backtest Settings:
Instrument: SPXUSD
Period: 2015.01 - 2016.12
Initial Capital: US$10,000
Data Interval: 1-day bar
Leverage: 1
https://algogene.com/community/post/61 5/7
2023/2/10 15:49 ALGOGENE | A trend following strategy based on volatility approach
Allow Shortsell: True
(/home)
Backtest Result:
Final Thoughts
The result above does not perform well. Below are some ideas to improve this trading strategy:
The current entry condition solely based on a non-zero smoothed value which is easy to trigger. Filter the
value by a certain threshold may increase the trend signal's accuracy.
Adding take profit/ stop loss level may be helpful to cut lost/gain earlier.
The MA period in this example is taken to be 60-day. Different smoothing period could be more
appropriate.
827
(/community/post/61?page=1) 1 (/community/post/61?page=1)
(/community/post/61?page=1)
About
ALGOGENE is the next generation investment platform for learning, developing, testing, executing, and investing trading bots!
Contact Us (/home#divContactUs)
Terms & Conditions (/terms)
Privacy Policy (/privacy)
Download App (/community/post/10)
Career Opportunity (/career)
https://algogene.com/community/post/61 6/7
2023/2/10 15:49 ALGOGENE | A trend following strategy based on volatility approach
Investor
Algo Marketplace (/marketplace#bot)
Community (/community)
Referral Program (/referral)
Robo-Trader (/community/post/16)
Robo-Advisor (/community/post/57)
Portfolio Builder (/services#divServicesPortfolio)
Enterprise Trading Solutions (/services#divServicesProject)
(https://www.linkedin.com/company/algogene-
financial-
technology-
(https://www.facebook.com/Algogene-
company- (https://github.com/algogene-
102449291574807) fintech)
(https://www.youtube.com/channel/UCKDkZCKPG3EBXnrPIUz6uMw)
limited)(https://www.instagram.com/algogene_fintech/)
(https://twitter.com/ALGOGENE_)
English
https://algogene.com/community/post/61 7/7