Program: 98368
Project: 98368
Buggy source:
@Override public void onBar(Instrument instrument,Period period,IBar askBar,IBar bidBar) throws JFException {
  if (!instrument.equals(this.instrument) || !period.equals(this.period))   return;
  if (askBar.getVolume() == 0 || bidBar.getVolume() == 0)   return;
  IBar histBar=history.getBar(instrument,period,OfferSide.BID,1);
  double[][] ha=indicators.heikenAshi(instrument,period,OfferSide.BID,indicatorFilter,numberOfCandlesBefore,histBar.getTime(),numberOfCandlesAfter);
  final int PREV=numberOfCandlesBefore + numberOfCandlesAfter - 1;
  final int OPEN=0;
  final int HIGH=3;
  final int LOW=2;
  final int CLOSE=1;
  double average=((ha[PREV][HIGH] - ha[PREV][LOW]) + (ha[PREV - 1][HIGH] - ha[PREV - 1][LOW])) / 2.0 * 10000;
  double spread=askPrice - bidPrice;
  stopLossPips=roundPips(mStopLossPips * average);
  if (stopLossPips < mStopLossPips)   return;
  double volume=getLotSize(account);
  takeProfitPips=roundPips(mTakeProfitPips * average);
  if (takeProfitPips < mTakeProfitPips)   return;
  if (!useStopLoss)   stopLossPips=0;
  double[][] dc=indicators.donchian(instrument,period,OfferSide.BID,dcTimePeriod,indicatorFilter,numberOfCandlesBefore,histBar.getTime(),numberOfCandlesAfter);
  final int UPPER=0;
  final int LOWER=1;
  double[] t3f=indicators.t3(instrument,period,OfferSide.BID,AppliedPrice.CLOSE,t3TimePeriodFast,t3VolumeFactor,indicatorFilter,numberOfCandlesBefore,histBar.getTime(),numberOfCandlesAfter);
  double[] t3s=indicators.t3(instrument,period,OfferSide.BID,AppliedPrice.CLOSE,t3TimePeriodSlow,t3VolumeFactor,indicatorFilter,numberOfCandlesBefore,histBar.getTime(),numberOfCandlesAfter);
  if (askPrice < t3f[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (order.isLong() && order.getProfitLossInPips() > mStopLossPips)         order.close();
      }
    }
  }
 else   if (bidPrice > t3f[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (!order.isLong() && order.getProfitLossInPips() > mStopLossPips)         order.close();
      }
    }
  }
  if (closeHugeLoss && askPrice > t3s[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (order.isLong() && order.getProfitLossInPips() < 0)         order.close();
      }
    }
  }
 else   if (closeHugeLoss && bidPrice < t3s[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (!order.isLong() && order.getProfitLossInPips() < 0)         order.close();
      }
    }
  }
  double amt=0;
  boolean uol=account.getUseOfLeverage() > maximumUoL;
  if (uol) {
    for (    IOrder order : engine.getOrders(instrument)) {
      if (order.getState() == IOrder.State.FILLED) {
        if (order.isLong())         amt+=order.getAmount();
 else         amt-=order.getAmount();
      }
    }
  }
  boolean longOk=(uol && amt > 0) ? false : true;
  boolean shortOk=(uol && amt < 0) ? false : true;
  if (verbose) {
    SimpleDateFormat bdf=new SimpleDateFormat("String_Node_Str");
    bdf.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
    console.getOut().printf("String_Node_Str",bdf.format(roundTime(histBar.getTime(),60000)));
    console.getOut().printf("String_Node_Str",Arrays.deepToString(ha));
    console.getOut().printf("String_Node_Str",Arrays.deepToString(dc));
    console.getOut().printf("String_Node_Str",Arrays.toString(t3f));
    console.getOut().printf("String_Node_Str",Arrays.toString(t3s));
    console.getOut().printf("String_Node_Str",bidPrice,askPrice,stopLossPips,takeProfitPips);
    console.getOut().printf("String_Node_Str",average,spread,volume);
    if (uol)     console.getOut().printf("String_Node_Str",amt,account.getUseOfLeverage());
  }
  if (longOk && bidPrice + spread < dc[LOWER][PREV] && dc[LOWER][PREV] < dc[LOWER][PREV - 1]) {
    double stopLossPrice=stopLossPips > 0 ? stopLossPrice=askPrice - getPipPrice(stopLossPips) : 0;
    double takeProfitPrice=askPrice + getPipPrice(takeProfitPips);
    console.getOut().printf("String_Node_Str",getLabel(instrument),instrument.name(),askPrice,volume,stopLossPrice,takeProfitPrice);
    IOrder order=engine.submitOrder(getLabel(instrument),instrument,OrderCommand.BUY,volume,askPrice,slippage,stopLossPrice,takeProfitPrice);
  }
  if (shortOk && askPrice > dc[UPPER][PREV] && dc[UPPER][PREV] > dc[UPPER][PREV - 1]) {
    double stopLossPrice=stopLossPips > 0 ? stopLossPrice=bidPrice + getPipPrice(stopLossPips) : 0;
    double takeProfitPrice=bidPrice - getPipPrice(takeProfitPips);
    console.getOut().printf("String_Node_Str",getLabel(instrument),instrument.name(),bidPrice,volume,stopLossPrice,takeProfitPrice);
    IOrder order=engine.submitOrder(getLabel(instrument),instrument,OrderCommand.SELL,volume,bidPrice,slippage,stopLossPrice,takeProfitPrice);
  }
}

Fixed version (ground truth):
@Override public void onBar(Instrument instrument,Period period,IBar askBar,IBar bidBar) throws JFException {
  if (!instrument.equals(this.instrument) || !period.equals(this.period))   return;
  if (askBar.getVolume() == 0 || bidBar.getVolume() == 0)   return;
  IBar prevBar=history.getBar(instrument,period,OfferSide.BID,1);
  double[][] ha=indicators.heikenAshi(instrument,period,OfferSide.BID,indicatorFilter,numberOfCandlesBefore,prevBar.getTime(),numberOfCandlesAfter);
  final int PREV=numberOfCandlesBefore + numberOfCandlesAfter - 1;
  final int OPEN=0;
  final int HIGH=3;
  final int LOW=2;
  final int CLOSE=1;
  double average=((ha[PREV][HIGH] - ha[PREV][LOW]) + (ha[PREV - 1][HIGH] - ha[PREV - 1][LOW])) / 2.0 * 10000;
  double spread=askPrice - bidPrice;
  stopLossPips=roundPips(mStopLossPips * average);
  if (stopLossPips < mStopLossPips)   return;
  double volume=getLotSize(account);
  takeProfitPips=roundPips(mTakeProfitPips * average);
  if (takeProfitPips < mTakeProfitPips)   return;
  if (!useStopLoss)   stopLossPips=0;
  double[][] dc=indicators.donchian(instrument,period,OfferSide.BID,dcTimePeriod,indicatorFilter,numberOfCandlesBefore,prevBar.getTime(),numberOfCandlesAfter);
  final int UPPER=0;
  final int LOWER=1;
  double[] t3f=indicators.t3(instrument,period,OfferSide.BID,AppliedPrice.CLOSE,t3TimePeriodFast,t3VolumeFactor,indicatorFilter,numberOfCandlesBefore,prevBar.getTime(),numberOfCandlesAfter);
  double[] t3s=indicators.t3(instrument,period,OfferSide.BID,AppliedPrice.CLOSE,t3TimePeriodSlow,t3VolumeFactor,indicatorFilter,numberOfCandlesBefore,prevBar.getTime(),numberOfCandlesAfter);
  if (askPrice < t3f[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (order.isLong() && order.getProfitLossInPips() > mStopLossPips)         order.close();
      }
    }
  }
 else   if (bidPrice > t3f[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (!order.isLong() && order.getProfitLossInPips() > mStopLossPips)         order.close();
      }
    }
  }
  if (closeHugeLoss && askPrice > t3s[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (order.isLong() && order.getProfitLossInPips() < 0)         order.close();
      }
    }
  }
 else   if (closeHugeLoss && bidPrice < t3s[PREV]) {
    for (    IOrder order : engine.getOrders()) {
      if (order.getLabel().substring(0,id.length()).equals(id) && order.getState() == IOrder.State.FILLED) {
        if (!order.isLong() && order.getProfitLossInPips() < 0)         order.close();
      }
    }
  }
  double amt=0;
  boolean uol=account.getUseOfLeverage() > maximumUoL;
  if (uol) {
    for (    IOrder order : engine.getOrders(instrument)) {
      if (order.getState() == IOrder.State.FILLED) {
        if (order.isLong())         amt+=order.getAmount();
 else         amt-=order.getAmount();
      }
    }
  }
  boolean longOk=(uol && amt > 0) ? false : true;
  boolean shortOk=(uol && amt < 0) ? false : true;
  if (verbose) {
    SimpleDateFormat bdf=new SimpleDateFormat("String_Node_Str");
    bdf.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
    console.getOut().printf("String_Node_Str",bdf.format(roundTime(prevBar.getTime(),60000)));
    console.getOut().printf("String_Node_Str",Arrays.deepToString(ha));
    console.getOut().printf("String_Node_Str",Arrays.deepToString(dc));
    console.getOut().printf("String_Node_Str",Arrays.toString(t3f));
    console.getOut().printf("String_Node_Str",Arrays.toString(t3s));
    console.getOut().printf("String_Node_Str",bidPrice,askPrice,stopLossPips,takeProfitPips);
    console.getOut().printf("String_Node_Str",average,spread,volume);
    if (uol)     console.getOut().printf("String_Node_Str",amt,account.getUseOfLeverage());
  }
  if (longOk && bidPrice + spread < dc[LOWER][PREV] && dc[LOWER][PREV] < dc[LOWER][PREV - 1]) {
    double stopLossPrice=stopLossPips > 0 ? stopLossPrice=askPrice - getPipPrice(stopLossPips) : 0;
    double takeProfitPrice=askPrice + getPipPrice(takeProfitPips);
    console.getOut().printf("String_Node_Str",getLabel(instrument),instrument.name(),askPrice,volume,stopLossPrice,takeProfitPrice);
    IOrder order=engine.submitOrder(getLabel(instrument),instrument,OrderCommand.BUY,volume,askPrice,slippage,stopLossPrice,takeProfitPrice);
  }
  if (shortOk && askPrice > dc[UPPER][PREV] && dc[UPPER][PREV] > dc[UPPER][PREV - 1]) {
    double stopLossPrice=stopLossPips > 0 ? stopLossPrice=bidPrice + getPipPrice(stopLossPips) : 0;
    double takeProfitPrice=bidPrice - getPipPrice(takeProfitPips);
    console.getOut().printf("String_Node_Str",getLabel(instrument),instrument.name(),bidPrice,volume,stopLossPrice,takeProfitPrice);
    IOrder order=engine.submitOrder(getLabel(instrument),instrument,OrderCommand.SELL,volume,bidPrice,slippage,stopLossPrice,takeProfitPrice);
  }
}