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

add CCI support #52

Merged
merged 1 commit into from
Apr 25, 2023
Merged

add CCI support #52

merged 1 commit into from
Apr 25, 2023

Conversation

tsuz
Copy link
Owner

@tsuz tsuz commented Apr 25, 2023

Tested using this PineScript code
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tak215

//@version=5
indicator("go-pine CCI 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)

cci = ta.cci(hlc3v, 4)

plot(c, color=color.yellow)

plot(cci , color=color.white)

@tsuz tsuz mentioned this pull request Apr 25, 2023
@tsuz tsuz merged commit 6244460 into main Apr 25, 2023
@tsuz tsuz deleted the taku/cci branch April 25, 2023 14:40
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.

1 participant