# Market analysis plotting

**URL:** <https://discourse.julialang.org/t/market-analysis-plotting/98543>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [May 9, 2023, 11:20am UTC](https://discourse.julialang.org/t/market-analysis-plotting/98543 "2023-05-09T11:20:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gudyrmik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gudyrmik/32/44687_2.png) [@gudyrmik](https://discourse.julialang.org/u/gudyrmik)\
**Post date:** [May 9, 2023, 11:20am UTC](https://discourse.julialang.org/t/market-analysis-plotting/98543/1 "2023-05-09T11:20:38Z")

</div>

Hello guys,  
I’m developing a fin. market analysis webapp and need to plot a price chart (OHLC data) with some additional simple graphics, like rectangles, polylines, curves, text. A plot doesn’t necessarily has to be interactive.  
An example from Metatrader looks like this:

 ![AUDJPY_ecnH4](https://global.discourse-cdn.com/julialang/original/3X/b/1/b16cb65d7e264edfeff28de0bf10e9b324d2481e.png)  
(don’t trade this! it is just an example of graphics)

Can you please advice me “the right package” for this?  
Thanks in advance and best regards.

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [May 9, 2023, 1:17pm UTC](https://discourse.julialang.org/t/market-analysis-plotting/98543/2 "2023-05-09T13:17:32Z")

</div>

I won’t trade that, it is rare to see someone into AUD/JPY,

Packages that can be used:

1. CSV
2. Dates
3. DataFrames
4. Plots
5. RollingFunctions

For example this code works, I tried before (if you want to load data from CSV from [investing.com](http://investing.com)):

```julia
using CSV, Dates, DataFrames, Plots, Plots.PlotMeasures, RollingFunctions

fileindy = "./csv/IDX-Stocks/INDY Historical Data.csv"

dfindy = CSV.read(fileindy, DataFrame)

dfindy.Price .= parse.(Float64, replace.(dfindy.Price, "," => ""))
dfindy[!,"Change %"] .= parse.(Float64, replace.(dfindy[!,"Change %"], "%" => ""))

dfindy.Dates = Date.(dfindy.Date, "mm/dd/yyyy")
tick_years = Date.(unique(Dates.year.(dfindy.Dates)))
DateTick = Dates.format.(tick_years, "yy")
xlimsindy = extrema([tick_years; dfindy.Dates])

p1 = plot(dfindy.Dates, dfindy.Price, title="",
    xticks=(tick_years,DateTick), xlims=xlimsindy,
    label="Indika Energy (Price)", xlabel="", ylabel="")

# Set up MA and Bollinger Band
prices = dfindy.Price;
moving_average = rollmean(prices, 20);
moving_std = rollstd(prices, 20);

bollinger_high = moving_average .+ 2moving_std;
bollinger_low = moving_average .- 2moving_std;

p2 = plot([moving_average bollinger_low bollinger_high], 
	label = ["Moving average" "Low" "High"], ls = [:solid :dash :dash])

plot(p1, p2, size=(900,800), layout = (2, 1), 
    legend=:outerright, left_margin=10mm, bottom_margin=5mm,
     xaxis = "", yaxis = "")

```

The plot should look like this  
 ![Capture d’écran_2023-05-09_20-13-52](https://global.discourse-cdn.com/julialang/original/3X/f/a/fab442aaa60c8667cb7a16b3c431cca77c5fc4a0.png)

If you want to build a hollow rectangle just use this for example:

```julia
plot!([2,2],[0,2], label="", linecolor=:green)
plot!([2,0],[2,2], label="", linecolor=:green)
plot!([0,2],[0,0], label="", linecolor=:green)
plot!([0,0],[2,0], label="", linecolor=:green)

...

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 9, 2023, 1:25pm UTC](https://discourse.julialang.org/t/market-analysis-plotting/98543/3 "2023-05-09T13:25:30Z")

</div>

I’d say a plot like this that’s noninteractive can be done in any plotting package, so if you want a specific recommendation you probably need to have stricter requirements 🙂

Here’s an example of a candlestick plot from some years ago, based on Plots.jl: [Julia add indicator to candlestick chart - Stack Overflow](https://stackoverflow.com/questions/71210151/julia-add-indicator-to-candlestick-chart)
