Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support ta.mfi #51

Merged
merged 5 commits into from
Apr 25, 2023
Merged

support ta.mfi #51

merged 5 commits into from
Apr 25, 2023

Conversation

tsuz
Copy link
Owner

@tsuz tsuz commented Apr 25, 2023

Fixes #24

@codecov
Copy link

codecov bot commented Apr 25, 2023

Codecov Report

Merging #51 (3b8ec2c) into main (0d00679) will increase coverage by 1.04%.
The diff coverage is 92.74%.

❗ Current head 3b8ec2c differs from pull request most recent head f3d27d0. Consider uploading reports for the commit f3d27d0 to get more accurate results

@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
+ Coverage   81.18%   82.23%   +1.04%     
==========================================
  Files          22       23       +1     
  Lines        1366     1486     +120     
==========================================
+ Hits         1109     1222     +113     
- Misses        192      196       +4     
- Partials       65       68       +3     
Impacted Files Coverage Δ
pine/series_mfi.go 85.48% <85.48%> (ø)
backtest/strategy_execute.go 100.00% <100.00%> (ø)
pine/ohlcv_series_base.go 79.16% <100.00%> (+2.85%) ⬆️
pine/series_change.go 68.91% <100.00%> (+1.31%) ⬆️
pine/testdata_ohlcv_no_gap.go 100.00% <100.00%> (ø)
pine/value_series.go 97.07% <100.00%> (+0.44%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tsuz
Copy link
Owner Author

tsuz commented Apr 25, 2023

MFI was test using this pinescript


//@version=5
indicator("go-pine MFI Test", overlay = false)

openval  = array.from(11.3, 12.9, 11.0, 19.2, 18.1, 19.4, 19.1, 10.6, 18.8, 17.1)
highval  = array.from(19.7, 19.1, 18.8, 19.6, 19.5, 19.8, 19.5, 19.9, 19.0, 17.6)
lowval   = array.from(11.1, 12.3, 10.3, 11.7, 11.2, 13.5, 12.9, 10.3, 12.4, 10.0)
closeval = array.from(16.5, 18.7, 18.2, 11.9, 19.3, 14.2, 14.4, 11.0, 14.7, 10.3)
volumeval= array.from(11.6, 13.0, 13.8, 15.9, 16.8, 19.1, 14.7, 11.7, 17.4, 15.0)

vals (index) =>
    if index >= 0 and array.size(closeval) > index
        [array.get(openval, int(index)),array.get(highval, int(index)),array.get(lowval, int(index)),array.get(closeval, int(index)), array.get(volumeval, int(index))]

sum_test (index) =>
    if index >= 0 and array.size(closeval) > index
        [array.get(openval, int(index)),array.get(highval, int(index)),array.get(lowval, int(index)),array.get(closeval, int(index)), array.get(volumeval, int(index))]

// the same on pine
pine_mfi(src, volsrc, length) =>
    float upper = math.sum(volsrc * (ta.change(src) <= 0.0 ? 0.0 : src), length)
    float lower = math.sum(volsrc * (ta.change(src) >= 0.0 ? 0.0 : src), length)
    mfi = 100.0 - (100.0 / (1.0 + upper / lower))
    mfi


[o, h, l, c, v] = vals(array.size(openval) - (last_bar_index - bar_index))

hlc3v = (h + l + c) / 3

mfi = pine_mfi(hlc3v, v, 4)

plot(mfi , color=color.white)

@tsuz tsuz merged commit 4ae6bd3 into main Apr 25, 2023
@tsuz tsuz deleted the taku/support-mfi branch April 25, 2023 13:49
@tsuz tsuz mentioned this pull request Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Indicators
1 participant