When it comes to trading cryptocurrencies, one of the most popular technical indicators used by traders is the Moving Average (MA). The MA is a trend-following indicator that calculates the average price of an asset over a certain period of time. As you know, by plotting multiple MAs on a price chart, traders can identify trends and potential buying and selling opportunities. *One specific trading strategy that uses the MA is the Moving Average Crossover (MAC) algorithm. This strategy is simple yet effective, and it can be used in any market, including the volatile cryptocurrency market. In this post, I will take a closer look at the MAC algorithm and how I used it with Hive price history.*  <center><sup>Photo by Anna Nekrashevich from [Pexels](https://www.pexels.com/photo/magnifying-glass-on-top-of-document-6801648/)</sup></center> --- To briefly mention for those who hear this concept for the first time, the MAC algorithm is a trend-following strategy that uses two MAs with different time periods. The most commonly used MAs in this strategy are the 50-day MA and the 200-day MA. When the shorter-term MA (50-day) crosses above the longer-term MA (200-day), it generates a buy signal, and when the shorter-term MA crosses below the longer-term MA, it generates a sell signal. This strategy is based on the assumption that when the price of an asset is above its MA (uptrend) and when the price is below its MA (downtrend). The MAC algorithm can identify both short-term and long-term trends in the market by using two MAs with different time periods. ## Using the MAC Algorithm on Hive Price History We will need to plot two MAs on a price chart to use the MAC algorithm. There are many option (trading platforms, charting softwares etc.) to do this. Once we have plotted the MAs, we can look for crossovers between them. When the short-term MA crosses above the long-term MA, it's a bullish signal, and we should consider buying the asset. When the short-term MA crosses below the long-term MA, it's a bearish signal, and we should consider selling the asset according the model. However, this is an assumption. It's important to note that the MAC algorithm can generate false signals in volatile markets. Mostly, it's recommended to use this strategy in conjunction with other technical indicators and trading tools to confirm the signals. But, in this post, I will only handle MAC algorithm here. In the code below, I first use the [yfinance](https://pypi.org/project/yfinance/) library to download Hive price data for the last 6 months. After that, I calculated the 50-day and 200-day moving averages of the price data using the rolling() method. Also, I created a new column for buy and sell signals based on the MAC algorithm. So, if the 50-day MA is greater than the 200-day MA, I assign a value of 1.0 to the Signal column that indicating a buy signal. If the 50-day MA is less than the 200-day MA vice-versa. At the first step I used matplotlib library to plot the buy and sell signals on a price chart. But I will use different option for better view. I first create a figure and set the y-axis label to 'Hive Price in USD'. Then plot the Hive price, 50-day MA, and 200-day MA on the chart. I also plot the buy signals as upward-pointing triangles and the sell signals as downward-pointing triangles. ``` import pandas as pd import yfinance as yf # Hive price data for the last 6 months hive = yf.download("HIVE-USD", start="2022-08-19", end="2023-02-19") # 50-day and 200-day MA hive['MA50'] = hive['Close'].rolling(window=50).mean() hive['MA200'] = hive['Close'].rolling(window=200).mean() # New column for buy and sell signals hive['Signal'] = 0.0 hive['Signal'] = np.where(hive['MA50'] > hive['MA200'], 1.0, 0.0) hive['Position'] = hive['Signal'].diff() # Buy and sell signals on a price chart import matplotlib.pyplot as plt # Probably I will use different plotting library fig = plt.figure() ax1 = fig.add_subplot(111, ylabel='Hive Price in USD') hive['Close'].plot(ax=ax1, color='r', lw=2.) hive['MA50'].plot(ax=ax1, color='b', lw=2.) hive['MA200'].plot(ax=ax1, color='g', lw=2.) # Plot buy and sell signals ax1.plot(hive.loc[hive.Position == 1.0].index, hive.Close[hive.Position == 1.0], '^', markersize=10, color='m') ax1.plot(hive.loc[hive.Position == -1.0].index, hive.Close[hive.Position == -1.0], 'v', markersize=10, color='k') plt.show() ``` <center>  </center> It looks like the price continues above the moving average. I leave it up to you to interpret the rest. In the code below I used the Plotly library to create an interactive chart that allows us to zoom in and out, hover over data points to see their values etc. Here first I created four different traces using the go.Scatter function: one for Hive price, one for the 50-day MA, one for the 200-day MA, and two for the buy and sell signals. The x and y parameters of each trace are set to the corresponding columns in the Hive dataframe. ``` import plotly.graph_objs as go # Traces for Hive price, 50-day MA, 200-day MA, buy signal and sell signal trace_price = go.Scatter( x=hive.index, y=hive['Close'], name='Hive Price' ) trace_ma50 = go.Scatter( x=hive.index, y=hive['MA50'], name='50-day MA' ) trace_ma200 = go.Scatter( x=hive.index, y=hive['MA200'], name='200-day MA' ) trace_buy = go.Scatter( x=hive[hive['Position'] == 1].index, y=hive['Close'][hive['Position'] == 1], name='Buy', mode='markers', marker=dict( symbol='triangle-up', size=10, color='green' ) ) trace_sell = go.Scatter( x=hive[hive['Position'] == -1].index, y=hive['Close'][hive['Position'] == -1], name='Sell', mode='markers', marker=dict( symbol='triangle-down', size=10, color='red' ) ) # Combine all traces into a data list data = [trace_price, trace_ma50, trace_ma200, trace_buy, trace_sell] # Layout for the chart layout = go.Layout( title='Hive Price with Moving Average Crossover Signals', yaxis=dict( title='Hive Price in USD' ) ) # Fig object and plot the chart fig = go.Figure(data=data, layout=layout) fig.show() ``` <center>  </center> **Important Note: The code I provided does not include any predictions or forecasting for the Hive price. The code simply generates buy and sell signals based on the Moving Average Crossover algorithm and visualizes the resulting signals on a chart. It is not an investment advice.** In fact, predicting future prices of cryptocurrencies is a complex and challenging task that requires more than just simple technical analysis. It involves a combination of factors such as market sentiment, news events, global economic conditions, more, more and more. I will be able to touch into various methods and models available for cryptocurrency price prediction, such as machine learning algorithms, time series analysis, and sentiment analyssis when I dive into them. Remember that predicting prices with high accuracy is still an active area of research and is subject to a high degree of uncertainty. Thank you for stopping by, Yaser Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@kedi/moving-average-crossover-on-hive-price-a-brief-look)
author | kedi |
---|---|
permlink | moving-average-crossover-on-hive-price-a-brief-look |
category | hive-167922 |
json_metadata | {"app":"leofinance/0.2","format":"markdown","tags":["cryptocurrencies","algorithmic-trading","python","hive","tr","leofinance","broofofbrain"],"canonical_url":"https://leofinance.io/@kedi/moving-average-crossover-on-hive-price-a-brief-look","links":["https://www.pexels.com/photo/magnifying-glass-on-top-of-document-6801648/","https://pypi.org/project/yfinance/"],"image":["https://i.imgur.com/ApU2WQo.jpg","https://i.imgur.com/kbNtnly.png","https://i.imgur.com/Caiw0vk.png"],"users":["kedi"]} |
created | 2023-02-19 12:39:15 |
last_update | 2023-02-19 13:14:30 |
depth | 0 |
children | 4 |
last_payout | 2023-02-26 12:39:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 6.471 HBD |
curator_payout_value | 6.441 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 7,470 |
author_reputation | 35,093,878,622,748 |
root_title | "Moving Average Crossover on Hive Price (A Brief Look)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 0 |
post_id | 120,920,050 |
net_rshares | 21,210,351,497,518 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
boatymcboatface | 0 | 148,604,080,267 | 8% | ||
yefet | 0 | 29,731,855,117 | 75% | ||
kingscrown | 0 | 20,821,222,823 | 8% | ||
theshell | 0 | 39,790,872,022 | 8% | ||
damla | 0 | 416,502,971,560 | 100% | ||
readmore | 0 | 1,033,597,273 | 100% | ||
talaxy | 0 | 10,979,904,800 | 100% | ||
ludmila.kyriakou | 0 | 74,941,854,175 | 100% | ||
sammystr | 0 | 672,621,237 | 100% | ||
orcunk.karaca | 0 | 2,879,885,697 | 50% | ||
pele23 | 0 | 340,731,918,873 | 52% | ||
tipu | 0 | 12,903,551,048,308 | 41% | ||
azdak0 | 0 | 1,074,719,642 | 100% | ||
dogancankilment | 0 | 7,221,378,033 | 100% | ||
benyamin | 0 | 17,897,446,752 | 100% | ||
murattatar | 0 | 835,734,082 | 20% | ||
ozanyaman | 0 | 1,023,605,282 | 100% | ||
afzalqamar | 0 | 1,695,362,837 | 20.5% | ||
farmerturkey | 0 | 2,327,415,386 | 100% | ||
ugurarslanboga | 0 | 791,969,444 | 50% | ||
ahmetay | 0 | 161,244,886,201 | 50% | ||
netknight | 0 | 2,575,746,496 | 100% | ||
whyshy | 0 | 6,275,752,610 | 100% | ||
kirazay | 0 | 7,811,688,321 | 50% | ||
artizm | 0 | 4,225,012,766 | 100% | ||
bartheek | 0 | 15,557,396,018 | 41% | ||
trliste | 0 | 164,462,955,802 | 100% | ||
baycan | 0 | 32,366,950,416 | 100% | ||
coinmeria | 0 | 755,357,308 | 35% | ||
ucmuharfli | 0 | 647,707,198 | 25% | ||
snlbaskurt | 0 | 26,952,327,035 | 90% | ||
lawyerslove | 0 | 500,499,097 | 100% | ||
atongis | 0 | 13,290,502,254 | 5% | ||
tobias-g | 0 | 3,802,949,952 | 20.5% | ||
uzercanan | 0 | 7,732,206,598 | 100% | ||
semihbalkanli | 0 | 847,135,888 | 100% | ||
sudefteri | 0 | 36,197,454,712 | 100% | ||
sjomeath | 0 | 896,580,052 | 20% | ||
ismocan | 0 | 624,569,368 | 30% | ||
ozkanozturkk | 0 | 826,904,196 | 50% | ||
akifane | 0 | 3,667,759,361 | 100% | ||
videoaddiction | 0 | 13,244,569,325 | 25% | ||
ruen | 0 | 6,044,568,682 | 100% | ||
muratkbesiroglu | 0 | 861,875,016,699 | 70% | ||
nikaja | 0 | 1,796,104,488 | 50% | ||
emotionalsea | 0 | 3,454,984,886 | 100% | ||
memepress | 0 | 653,859,162 | 20.5% | ||
roinv | 0 | 570,463,371 | 15% | ||
cryptocengineer | 0 | 1,961,606,616 | 100% | ||
sahinadm | 0 | 1,180,718,170 | 100% | ||
kahvesizlik | 0 | 1,287,492,626 | 100% | ||
longer | 0 | 3,514,269,068 | 10.25% | ||
mightypanda | 0 | 950,353,169 | 28.7% | ||
wagner32 | 0 | 32,441,658,865 | 100% | ||
geographer | 0 | 1,120,485,903 | 100% | ||
naty16 | 0 | 1,491,676,741 | 4.1% | ||
brianoflondon | 0 | 3,800,967,829,066 | 100% | ||
bidesign | 0 | 488,642,458 | 50% | ||
bluedwains | 0 | 962,458,976 | 50% | ||
apokruphos | 0 | 9,059,127,676 | 3% | ||
mia-cc | 0 | 5,257,083,257 | 41% | ||
gamzekablan23 | 0 | 619,516,615 | 50% | ||
denizcakmak | 0 | 602,003,532 | 50% | ||
kryptogames | 0 | 154,474,190,362 | 41% | ||
cryptogambit | 0 | 1,444,869,138 | 7.5% | ||
bcm | 0 | 3,703,500,401 | 30.75% | ||
dappstats | 0 | 4,003,067,468 | 15% | ||
blocktvnews | 0 | 863,519,625 | 50% | ||
julesquirin | 0 | 1,919,393,797 | 8.2% | ||
mehmetfix | 0 | 18,012,215,968 | 100% | ||
cornavirus | 0 | 8,989,603,464 | 90% | ||
sunsan | 0 | 51,016,996,926 | 100% | ||
musictime2020 | 0 | 1,932,102,895 | 50% | ||
koshwe | 0 | 1,691,525,980 | 50% | ||
blockbroccoli | 0 | 760,735,982 | 36.9% | ||
princeofbeyhive | 0 | 6,688,416,852 | 50% | ||
selimhaki | 0 | 497,070,530 | 100% | ||
motivationrainn | 0 | 13,470,948,659 | 100% | ||
hivehydra | 0 | 788,626,500 | 90% | ||
podping | 0 | 501,663,709,581 | 100% | ||
yoieuqudniram | 0 | 2,029,621,225 | 20.5% | ||
shatargat | 0 | 1,988,753,344 | 50% | ||
gokturk70 | 0 | 3,224,623,241 | 50% | ||
cryptoccshow | 0 | 5,954,055,000 | 50% | ||
bilgin70 | 0 | 38,831,130,994 | 50% | ||
flsfserkan | 0 | 71,175,072,462 | 100% | ||
canser | 0 | 13,314,442,007 | 100% | ||
cryptothesis | 0 | 229,988,492,663 | 100% | ||
proofofbrian | 0 | 446,360,091 | 100% | ||
mttok | 0 | 67,314,079,478 | 100% | ||
passenger777 | 0 | 83,957,782,281 | 100% | ||
pinkfurby | 0 | 2,775,427,828 | 100% | ||
aysegultravel | 0 | 2,054,751,139 | 100% | ||
dusunenkalpp | 0 | 27,824,338,323 | 80% | ||
oneplanet | 0 | 8,180,295,850 | 100% | ||
zeynos | 0 | 1,959,142,298 | 100% | ||
barika | 0 | 8,717,247,686 | 100% | ||
angelnature777 | 0 | 8,086,614,360 | 100% | ||
favian | 0 | 887,452,337 | 100% | ||
sabajfa | 0 | 1,621,836,314 | 20.5% | ||
kam5iz | 0 | 5,139,273,323 | 16.4% | ||
bilginselcuk | 0 | 22,405,409,190 | 100% | ||
crazygirl777 | 0 | 12,275,966,435 | 100% | ||
xtipu | 0 | -488,372,331 | -41% | ||
homeopath | 0 | 2,481,939,259 | 50% | ||
mukadder | 0 | 33,899,163,349 | 50% | ||
dolunay18 | 0 | 12,855,578,633 | 70% | ||
incublus | 0 | 348,344,967,022 | 50% | ||
ezgicop | 0 | 22,691,901,405 | 100% | ||
yagmurzamani | 0 | 905,560,349 | 100% | ||
bilginhilal | 0 | 76,076,157,737 | 99% | ||
kilic60 | 0 | 1,091,122,652 | 100% | ||
sezermehmet | 0 | 19,135,618,419 | 100% | ||
archatlas | 0 | 3,872,335,106 | 100% | ||
sandra11 | 0 | 3,233,520,192 | 90% | ||
davchi2 | 0 | 4,186,471,729 | 100% | ||
catslovers | 0 | 13,959,949,108 | 90% | ||
incublus.hivegc | 0 | 3,248,259,539 | 100% | ||
pinkfurby5 | 0 | 2,975,356,869 | 100% | ||
bemier | 0 | 5,893,011,874 | 100% | ||
ass.hole | 0 | 0 | 1% |
Congratulations @kedi! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s) <table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@kedi/upvotes.png?202302201227"></td><td>You distributed more than 14000 upvotes.<br>Your next target is to reach 15000 upvotes.</td></tr> </table> <sub>_You can view your badges on [your board](https://hivebuzz.me/@kedi) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub> **Check out our last posts:** <table><tr><td><a href="/hive-139531/@hivebuzz/proposal-2324"><img src="https://images.hive.blog/64x128/https://i.imgur.com/RNIZ1N6.png"></a></td><td><a href="/hive-139531/@hivebuzz/proposal-2324">The Hive Gamification Proposal</a></td></tr></table>
author | hivebuzz |
---|---|
permlink | notify-kedi-20230220t132206 |
category | hive-167922 |
json_metadata | {"image":["http://hivebuzz.me/notify.t6.png"]} |
created | 2023-02-20 13:22:06 |
last_update | 2023-02-20 13:22:06 |
depth | 1 |
children | 0 |
last_payout | 2023-02-27 13:22:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 901 |
author_reputation | 369,213,166,930,843 |
root_title | "Moving Average Crossover on Hive Price (A Brief Look)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 120,950,467 |
net_rshares | 0 |
Here is your Proof of Brian. I think you meant #ProofOfBrain  [Source](https://commons.wikimedia.org/wiki/File:Professor_Brian_Cox_OBE_FRS.jpg)
author | proofofbrian |
---|---|
permlink | re-moving-average-crossover-on-hive-price-a-brief-look-20230219t123920z |
category | hive-167922 |
json_metadata | "{"app": "beem/0.24.26"}" |
created | 2023-02-19 12:39:21 |
last_update | 2023-02-19 12:39:21 |
depth | 1 |
children | 0 |
last_payout | 2023-02-26 12:39:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 280 |
author_reputation | 707,015,257,900 |
root_title | "Moving Average Crossover on Hive Price (A Brief Look)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 120,920,051 |
net_rshares | 0 |
@tipu curate 5
author | trliste |
---|---|
permlink | re-kedi-rqcbs4 |
category | hive-167922 |
json_metadata | {"tags":["hive-167922"],"app":"peakd/2023.2.2"} |
created | 2023-02-19 18:38:36 |
last_update | 2023-02-19 18:38:36 |
depth | 1 |
children | 1 |
last_payout | 2023-02-26 18:38:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 14 |
author_reputation | 67,270,310,991,216 |
root_title | "Moving Average Crossover on Hive Price (A Brief Look)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 120,928,268 |
net_rshares | 0 |
<a href="https://tipu.online/hive_curator?trliste" target="_blank">Upvoted 👌</a> (Mana: 0/41) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
author | tipu |
---|---|
permlink | re-re-kedi-rqcbs4-20230219t183842z |
category | hive-167922 |
json_metadata | "{"app": "beem/0.24.26"}" |
created | 2023-02-19 18:38:42 |
last_update | 2023-02-19 18:38:42 |
depth | 2 |
children | 0 |
last_payout | 2023-02-26 18:38:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 214 |
author_reputation | 55,909,940,232,228 |
root_title | "Moving Average Crossover on Hive Price (A Brief Look)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 120,928,272 |
net_rshares | 0 |