Как разделить два Low [1] на оператор if? - PullRequest
0 голосов
/ 04 июля 2019

Пример, предыдущий минимум - 1,55.Когда следующий минимум свечи равен 1,66, то следующий следующий минимум свечи равен 1,44, что ниже, чем предыдущий минимум (1,55), тогда сделайте что-нибудь.Как этого добиться?

double previous_low = 0;
double new_low = 0;
double new_low2 = 0;
if (((previous_low==0)&&(Low[1] < Low[2])){
     previous_low = Low[1];
}
if (previous_low != 0){
     if (Low[1] < previous_low){
          new_low2 = Low[1]; //it fail
     }
     if (Low[0] < previous_low){
          new_low2 = Low[0]; //it works only if next 1 candle is lower than previous. It fail if next 2 candle is lower than previous_low.
     }
}

1 Ответ

0 голосов
/ 04 июля 2019

Это может быть достигнуто с помощью пузырьковой сортировки

 public class BubbleSort 
    { 
        void bubbleSort(double arr[]) 
        { 
            int n = arr.length; 
            for (int i = 0; i < n-1; i++) 
                for (int j = 0; j < n-i-1; j++) 
                    if (arr[j] > arr[j+1]) 
                    { 
                         System.out.print("first value :"+arr[j]+" greater than" +"previos :"+arr[j+1] + " ");
                          System.out.println(); 
                        // swap arr[j+1] and arr[i] 
                        double temp = arr[j]; 
                        arr[j] = arr[j+1]; 
                        arr[j+1] = temp; 
                    } 
        } 

        /* Prints the array */
        void printArray(double arr[]) 
        { 
            int n = arr.length; 
            for (int i=0; i<n; ++i) 
                System.out.print(arr[i] + " "); 
            System.out.println(); 
        } 

        // Driver method to test above 
        public static void main(String args[]) 
        { 
            BubbleSort ob = new BubbleSort(); 
            double arr[] = {1.66, 1.55, 1.44}; 
            ob.bubbleSort(arr); 
            System.out.println("Sorted array"); 
            ob.printArray(arr); 
        } 
    }
...