Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 确定字符串组合MQL4频率的算法_Algorithm_Combinations_Mql4 - Fatal编程技术网

Algorithm 确定字符串组合MQL4频率的算法

Algorithm 确定字符串组合MQL4频率的算法,algorithm,combinations,mql4,Algorithm,Combinations,Mql4,我有如下csv文件: 1392249600;EUR;CHF;USD;JPY;GBP 1392163200;GBP;JPY;USD;CHF;EUR 1392076800;GBP;CHF;EUR;JPY;USD 1391990400;JPY;USD;EUR;CHF;GBP 1391904000;GBP;EUR;CHF;USD;JPY 1391731200;GBP;EUR;CHF;JPY;USD 1391644800;EUR;CHF;USD;JPY;GBP 1391558400;JPY;USD;EUR

我有如下csv文件:

1392249600;EUR;CHF;USD;JPY;GBP
1392163200;GBP;JPY;USD;CHF;EUR
1392076800;GBP;CHF;EUR;JPY;USD
1391990400;JPY;USD;EUR;CHF;GBP
1391904000;GBP;EUR;CHF;USD;JPY
1391731200;GBP;EUR;CHF;JPY;USD
1391644800;EUR;CHF;USD;JPY;GBP
1391558400;JPY;USD;EUR;CHF;GBP
该文件中可能有15000多行。我正在尝试编写代码来完成以下任务:

1.获取第一行并将其保存为父行。然后在接下来的三天里,孩子们就这样

2.统计此文件中包含该父项的子项的频率和组合

3.它创建了类似于总结的内容,这样我就可以阅读今天的组合,脚本显示了未来3天中最常见的子组合

我没有数学思维,所以我有大问题要自己去解决

首先,我需要一个脚本来生成所有可能的组合,这些组合由欧元、瑞士法郎、美元、日元、英镑组成,所以有可能的5*4*3*2*1=120个组合。因为他们不能在一行重复

会是这样的


第一个父项将是第一行的组合,如下所示:欧元;瑞士法郎;美元;日元;;英镑

Then 3 childs would be
  GBP;JPY;USD;CHF;EUR 
  GBP;CHF;EUR;JPY;USD
  JPY;USD;EUR;CHF;GBP
它保存父元素和子元素的这种组合。 然后,它再次从文件的开头开始,但在下面移动一行(如迭代+1)。 然后接下来所有的孩子都会

 GBP;CHF;EUR;JPY;USD
   JPY;USD;EUR;CHF;GBP
   GBP;EUR;CHF;USD;JPY
再次,它保存这些组合用于计数,并生成一些频率结果。 这个循环对csv文件中的所有行重复

<>也许有一些技巧我应该考虑如何创建这类程序?

任何小费都好

多谢各位!
BB

能否请您澄清文件行中的第一个值是否为日期/时间?1392249600;欧元;瑞士法郎;美元;日元;;英镑

Then 3 childs would be
  GBP;JPY;USD;CHF;EUR 
  GBP;CHF;EUR;JPY;USD
  JPY;USD;EUR;CHF;GBP
如果是,您是否希望总共有4行具有相同的日期/时间

或者你只需要按顺序使用第1行作为父行,然后第2行、第3行、第4行作为子行,然后继续。。。那么第5行又成了父行了

要检查国家代码是否等效,您可以使用以下代码类型。我不是100%确定您的要求,如果您认为这不是您想要的,请纠正我,我将尝试以其他方式回答您:

package com.collections;

public class CountryCodeComparison {
    public static void main(String[] args) {
        //Read every row and sequentially insert value in CountryCode object.
        //For ex. your row is: 1392163200;GBP;JPY;USD;CHF;EUR
        String s1 = "1392163200;GBP;JPY;USD;CHF;EUR";
        String [] array1 = s1.split(";");
        CountryCode  cc1 = new CountryCode(array1[1], array1[2], array1[1], array1[4], array1[5]);

        //For ex. your row is: 1392076800;GBP;CHF;EUR;JPY;USD
        String s2 = "1392076800;GBP;CHF;EUR;JPY;USD";
        String [] array2 = s2.split(";");
        CountryCode  cc2 = new CountryCode(array2[1], array2[2], array2[1], array2[4], array2[5]);

        if(cc1.equals(cc2)) {
            System.out.println("Both CountryCode objects are equal.");
        } else {
            System.out.println("Both CountryCode objects are NOT equal.");
        }
    }
}

class CountryCode {
    private String countryCode1;
    private String countryCode2;
    private String countryCode3;
    private String countryCode4;
    private String countryCode5;
    public CountryCode(String countryCode1, String countryCode2,
            String countryCode3, String countryCode4, String countryCode5) {
        this.countryCode1 = countryCode1;
        this.countryCode2 = countryCode2;
        this.countryCode3 = countryCode3;
        this.countryCode4 = countryCode4;
        this.countryCode5 = countryCode5;
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((countryCode1 == null) ? 0 : countryCode1.hashCode());
        result = prime * result
                + ((countryCode2 == null) ? 0 : countryCode2.hashCode());
        result = prime * result
                + ((countryCode3 == null) ? 0 : countryCode3.hashCode());
        result = prime * result
                + ((countryCode4 == null) ? 0 : countryCode4.hashCode());
        result = prime * result
                + ((countryCode5 == null) ? 0 : countryCode5.hashCode());
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        CountryCode other = (CountryCode) obj;
        if (countryCode1 == null) {
            if (other.countryCode1 != null)
                return false;
        } else if (!countryCode1.equals(other.countryCode1))
            return false;
        if (countryCode2 == null) {
            if (other.countryCode2 != null)
                return false;
        } else if (!countryCode2.equals(other.countryCode2))
            return false;
        if (countryCode3 == null) {
            if (other.countryCode3 != null)
                return false;
        } else if (!countryCode3.equals(other.countryCode3))
            return false;
        if (countryCode4 == null) {
            if (other.countryCode4 != null)
                return false;
        } else if (!countryCode4.equals(other.countryCode4))
            return false;
        if (countryCode5 == null) {
            if (other.countryCode5 != null)
                return false;
        } else if (!countryCode5.equals(other.countryCode5))
            return false;
        return true;
    }
}

是的,是日期时间,但它不应该重复,我的意思是永远。我没有提到父元素每次移动到下一行。所以它会检查所有的父母和他们的孩子。你是想根据日期来分组吗?很抱歉,我无法确定您将如何决定哪一个是家长及其子女?第一个家长将是第一行的组合。我会更新我的问题