Here is a similar implementation of the same concept in Java:

```java
import java.util.ArrayList;
import java.util.List;

public class BuySellStrategy {
    public static void main(String[] args) {
        List<Double> closePrices = new ArrayList<>();
        // Load the stock data and add to the closePrices list

        // Calculate the MACD line and signal line
        double[] macd = new double[closePrices.size()];
        double[] signal = new double[closePrices.size()];
        double[] hist = new double[closePrices.size()];
        int fastPeriod = 12;
        int slowPeriod = 26;
        int signalPeriod = 9;
        // Implementation of MACD calculation goes here

        // Create a new list to store the MACD values
        List<Double> macdList = new ArrayList<>();
        List<Double> signalList = new ArrayList<>();
        List<Double> histList = new ArrayList<>();
        for (int i = 0; i < macd.length; i++) {
            macdList.add(macd[i]);
            signalList.add(signal[i]);
            histList.add(hist[i]);
        }
        
        // Create a new list 'positions' to store the trading signal
        List<Integer> positions = new ArrayList<>();
        for (int i = 0; i < macdList.size(); i++) {
            if (macdList.get(i) > signalList.get(i)) {
                positions.add(1);
            } else {
                positions.add(-1);
            }
        }
        
        // Shift the signal by 1 to avoid the signal for the current day
        positions.remove(0);
        positions.add(0, 0);
        
        // Create a new list 'strategy' to store the cumulative return of the strategy
        List<Double> strategy = new ArrayList<>();
        for (int i = 0; i < closePrices.size(); i++) {
            double cumReturn = (closePrices.get(i) - closePrices.get(i - 1)) / closePrices.get(i - 1);
            strategy.add(cumReturn * positions.get(i - 1));
        }
        
        // Plot the cumulative return of the strategy
        // Plotting library needs to be added for this
    }
}```
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence