Please help!!!......the historical backtest gives me trades...but the demo local run no trades at all.....help with this code would be appreciated!!!.
package pinto ;
import java.util.*;
import com.dukascopy.api.*;
public class pinto implements IStrategy {
private IEngine engine;
private IConsole console;
private IUserInterface userInterface;
private IAccount account;
private IHistory history;
private IContext context;
private IIndicators indicators;
public int SL = 30;
public int TP =17;
public Instrument instrument = Instrument.GBPUSD;
public Period period = Period.FIFTEEN_MINS;
public double SLIPPAGE = 5;
public int counter = 0;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
}
public void onStop() throws JFException {
}
public void onAccount(IAccount account) throws JFException {
this.account = account;
}
public void onMessage(IMessage message) throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException
{
if (instrument != this.instrument) return;
if (period != this.period) return;
double Lot = .50;
double PIP = instrument.getPipValue();
int pos=0;
for (IOrder order : engine.getOrders(instrument)) {
if (order.getState() == IOrder.State.FILLED) {
if (order.isLong()) pos=1;
else pos=-1;
if (SL>0 && order.getStopLossPrice()==0) order.setStopLossPrice(order.getOpenPrice() - pos*PIP*SL);
if (TP>0 && order.getTakeProfitPrice()==0) order.setTakeProfitPrice(order.getOpenPrice() + pos*PIP*TP);
}
}
if (pos==0) {
double macd0 = indicators.macd(Instrument.GBPUSD, Period.TWENTY_MINS,
OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 2,3,3, 0)[0];
double signal0 = indicators.macd(Instrument.GBPUSD,
Period.TWENTY_MINS, OfferSide.BID,
IIndicators.AppliedPrice.CLOSE, 2,3,3, 0)[1];
double macd1 = indicators.macd(Instrument.GBPUSD, Period.TWENTY_MINS,
OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 2,3, 3, 1)[0];
double signal1 = indicators.macd(Instrument.GBPUSD,
Period.TWENTY_MINS, OfferSide.BID,
IIndicators.AppliedPrice.CLOSE, 2, 3,3, 1)[1];
Date datetime = new Date(askBar.getTime());
int day = datetime.getDate();
if ((macd0 > signal0 && macd1 < signal1))
engine.submitOrder("S"+(day*100+counter++), instrument, IEngine.OrderCommand.SELL, Lot, 0, SLIPPAGE);
if ((macd0 < signal0 && macd1 > signal1))
engine.submitOrder("B"+(day*100+counter++), instrument, IEngine.OrderCommand.BUY, Lot, 0, SLIPPAGE);
}
}
}