Giter VIP home page Giter VIP logo

kdemo's People

Contributors

jackysheng avatar zhangliangzs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kdemo's Issues

MACD的算法有点问题

MACD算法公式:
(1)12日的EMA计算:EMA(12)=昨日EMA(12)×11 + c(今日)×2
13 13 13
(2)26日的EMA计算:EMA(26)=昨日EMA(26)×25 + c(今日)×2
27 27 27
(3)DIFF=EMA(12)-EMA(26)
(4)9日的DEA计算:DEA=昨日DEA×8 + 今日DIF×2
10 10
(5)MACD计算:MACD=(DIFF-DEA)×2

从后面往前面取值这种算法不是很可取,我认为的正确算法:
public class MACD {

private List<Double> DEAs;
private List<Double> DIFs;
private List<Double> BARs;

private List<Double> EMA12;
private List<Double> EMA26;
private EMAEntity mEMAEntity9;
private EMAEntity mEMAEntity12;
private EMAEntity mEMAEntity26;

public MACD(List<Float> OHLCData) {
 ......
    if (OHLCData != null && OHLCData.size() > 0) {

        for (int i = 0; i <= OHLCData.size() - 1; i++) {
            dIF = EMA12.get(i)-EMA26.get(i);
            if (i == 0) {
                dEA = 0+dIF*(2/10);
                mBAR = 0.0;
            } else {
                dEA = dEA*0.8 + dIF*0.2;
                mBAR = 2*(dIF-dEA);
            }
            dEAs.add(dEA);
            dIFs.add(dIF);
            mBARs.add(mBAR);
        }

            DEAs.addAll(dEAs);
            DIFs.addAll(dIFs);
            BARs.addAll(mBARs);
    }

......
}

public class EMAEntity {
private List EMAs;

public EMAEntity(List<MarketChartData> OHLCData, int n)
{
    EMAs = new ArrayList<Double>();
    if (OHLCData != null && OHLCData.size() > 0) {
        double close = 0;
        double EMA12 = 0.0;
        MarketChartData oHLCEntity;
        for (int i = 0; i <= OHLCData.size() - 1; i++) {
            close = OHLCData.get(i).getClosePrice();
            oHLCEntity = OHLCData.get(i);
            if (i ==0) {
                EMA12 = oHLCEntity.getClosePrice();
                EMAs.add(EMA12);
            }else
            {
                EMA12 = EMAs.get(EMAs.size()-1)*(n-1)/(n+1)+close*(2)/(n+1);
                EMAs.add(EMA12);
            }
        }

    }
}
public List<Double> getnEMA() {
    return EMAs;
}

}

Scrollview

Scrollview套Kview,kview就显示不出来了

关于本demo

为什么我下载了demo之后,运行,根本没有数据显示出来?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.