Q1 Import Tesla for the last one year.

Hint: Copy and revise the importing part of the code from above.

## # A tibble: 251 x 7
##    date        open  high   low close   volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 2018-10-24  301.  304.  286.  288. 20058300     288.
##  2 2018-10-25  317.  321   301.  315. 20840700     315.
##  3 2018-10-26  308.  340.  307.  331. 27425500     331.
##  4 2018-10-29  337.  347.  326.  335. 14486000     335.
##  5 2018-10-30  328.  338.  322.  330.  9126700     330.
##  6 2018-10-31  333.  342   329.  337.  7624300     337.
##  7 2018-11-01  338.  348.  335.  344.  8000100     344.
##  8 2018-11-02  344.  349.  341.  346.  7808000     346.
##  9 2018-11-05  340.  344.  330.  341.  7831000     341.
## 10 2018-11-06  339.  349.  336.  341.  6762900     341.
## # … with 241 more rows

Q2 Calculate 15-day and 50-day simple moving averages.

Hint: Copy and revise the moving average part of the code from above.

## # A tibble: 251 x 9
##    date        open  high   low close   volume adjusted SMA.short SMA.long
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>     <dbl>    <dbl>
##  1 2018-10-24  301.  304.  286.  288. 20058300     288.       NA        NA
##  2 2018-10-25  317.  321   301.  315. 20840700     315.       NA        NA
##  3 2018-10-26  308.  340.  307.  331. 27425500     331.       NA        NA
##  4 2018-10-29  337.  347.  326.  335. 14486000     335.       NA        NA
##  5 2018-10-30  328.  338.  322.  330.  9126700     330.      320.       NA
##  6 2018-10-31  333.  342   329.  337.  7624300     337.      330.       NA
##  7 2018-11-01  338.  348.  335.  344.  8000100     344.      335.       NA
##  8 2018-11-02  344.  349.  341.  346.  7808000     346.      339.       NA
##  9 2018-11-05  340.  344.  330.  341.  7831000     341.      340.       NA
## 10 2018-11-06  339.  349.  336.  341.  6762900     341.      342.       NA
## # … with 241 more rows

Q3 Transform data to long form from wide form for graphing.

Hint: Copy and revise the transformation part of the code from above.

## # A tibble: 753 x 3
##    date       type  price
##    <date>     <chr> <dbl>
##  1 2018-10-24 close  288.
##  2 2018-10-25 close  315.
##  3 2018-10-26 close  331.
##  4 2018-10-29 close  335.
##  5 2018-10-30 close  330.
##  6 2018-10-31 close  337.
##  7 2018-11-01 close  344.
##  8 2018-11-02 close  346.
##  9 2018-11-05 close  341.
## 10 2018-11-06 close  341.
## # … with 743 more rows

Q4 Visualize data.

Hint: Copy and revise the visualization part of the code from above.

Q5 If you had invested $1 million on the day of the first bullish crossover and sold your shares on the following bearish crosover, how much would you have won or lost?

On July 2nd 2019 if we invest a million dollars we can buy 224.55 stocks on the fist bullish crossover. On Auguest 16th 2019, on the bearish crossover, the clsoing price was 219.94. So yopu would have lost $20,529.95.

Q6 The bullish crossover missed the actual bottom. How long (in days) was the time lag?

The time lag would have been 29 days.

Q7 What would you change in the moving average model to reduce the time lag? Create another chart below with the change, and count the reduced time lag (in days).

## # A tibble: 251 x 7
##    date        open  high   low close   volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 2018-10-24  301.  304.  286.  288. 20058300     288.
##  2 2018-10-25  317.  321   301.  315. 20840700     315.
##  3 2018-10-26  308.  340.  307.  331. 27425500     331.
##  4 2018-10-29  337.  347.  326.  335. 14486000     335.
##  5 2018-10-30  328.  338.  322.  330.  9126700     330.
##  6 2018-10-31  333.  342   329.  337.  7624300     337.
##  7 2018-11-01  338.  348.  335.  344.  8000100     344.
##  8 2018-11-02  344.  349.  341.  346.  7808000     346.
##  9 2018-11-05  340.  344.  330.  341.  7831000     341.
## 10 2018-11-06  339.  349.  336.  341.  6762900     341.
## # … with 241 more rows
## # A tibble: 251 x 9
##    date        open  high   low close   volume adjusted SMA.short SMA.long
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>     <dbl>    <dbl>
##  1 2018-10-24  301.  304.  286.  288. 20058300     288.       NA        NA
##  2 2018-10-25  317.  321   301.  315. 20840700     315.       NA        NA
##  3 2018-10-26  308.  340.  307.  331. 27425500     331.       NA        NA
##  4 2018-10-29  337.  347.  326.  335. 14486000     335.       NA        NA
##  5 2018-10-30  328.  338.  322.  330.  9126700     330.       NA        NA
##  6 2018-10-31  333.  342   329.  337.  7624300     337.       NA        NA
##  7 2018-11-01  338.  348.  335.  344.  8000100     344.       NA        NA
##  8 2018-11-02  344.  349.  341.  346.  7808000     346.       NA        NA
##  9 2018-11-05  340.  344.  330.  341.  7831000     341.       NA        NA
## 10 2018-11-06  339.  349.  336.  341.  6762900     341.      331.       NA
## # … with 241 more rows
## # A tibble: 753 x 3
##    date       type  price
##    <date>     <chr> <dbl>
##  1 2018-10-24 close  288.
##  2 2018-10-25 close  315.
##  3 2018-10-26 close  331.
##  4 2018-10-29 close  335.
##  5 2018-10-30 close  330.
##  6 2018-10-31 close  337.
##  7 2018-11-01 close  344.
##  8 2018-11-02 close  346.
##  9 2018-11-05 close  341.
## 10 2018-11-06 close  341.
## # … with 743 more rows

I would change the simple moving average to account for the 15 and 50 day simple moving averages rather than 100 and 50, to 10 and 30.

Q8 Hide the messages and the code, but display results of the code from the webpage.

Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.