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 support for cross, crossover and crossunder #55

Merged
merged 3 commits into from
Apr 27, 2023
Merged

Conversation

tsuz
Copy link
Owner

@tsuz tsuz commented Apr 27, 2023

Tested using this pinescript

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


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

hlc3v = (h + l + c) / 3


// the same on pine
f_bb(src, length, mult) =>
    float basis = ta.sma(src, length)
    float dev = mult * ta.stdev(src, length)
    [basis, basis + dev, basis - dev]

co = ta.crossover(c, o)
co2 = ta.crossunder(c, o)
co3 = ta.cross(c, o)
// [m1, u1, l1] = f_bb(c, 4, 2.5)

// plot(adx2-adx , color=color.white)
plot(c, color=color.blue)
plot(co3  ? 1.0:0.0, color=color.yellow)

@tsuz tsuz changed the title add crossover func add crossover (ta.crossover) support Apr 27, 2023
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #55 (6495b7e) into main (16f9654) will increase coverage by 0.06%.
The diff coverage is 91.89%.

❗ Current head 6495b7e differs from pull request most recent head c25aadd. Consider uploading reports for the commit c25aadd to get more accurate results

@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
+ Coverage   81.61%   81.68%   +0.06%     
==========================================
  Files          27       28       +1     
  Lines        1632     1654      +22     
==========================================
+ Hits         1332     1351      +19     
- Misses        219      221       +2     
- Partials       81       82       +1     
Impacted Files Coverage Δ
pine/series_crossover.go 85.00% <85.00%> (ø)
pine/series_mfi.go 86.95% <100.00%> (+1.47%) ⬆️
pine/value_series.go 97.00% <100.00%> (-0.08%) ⬇️

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

@tsuz tsuz changed the title add crossover (ta.crossover) support add support for cross, crossover and crossunder Apr 27, 2023
@tsuz tsuz merged commit f5604e9 into main Apr 27, 2023
@tsuz tsuz deleted the taku/crossover branch April 27, 2023 12:35
@tsuz tsuz mentioned this pull request Apr 27, 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.

1 participant