|
Strange phenomenun Order send problem with Remote Server |
germain
|
Post subject: Strange phenomenun Order send problem with Remote Server |
Post rating: 0
|
Posted: Mon 26 Nov, 2012, 18:35
|
|
User rating: 0
Joined: Mon 26 Nov, 2012, 16:32 Posts: 11 Location: JapanJapan
|
Hello, i wrote a simple code which strangely works on "Local Run". When i compile the code i got the message "Compilation successful". Ok... But when i run it, Sometimes, it's like a random function on currency pairs... Sometimes i open EURUSD, sometimes EURJPY or GBPUSD.... nonsense.... And sometimes i got the message: "java.lang.NullPointerException", But i don't know where's come from all those errors.... Why i don't get EURUSD order instead of getting USDCHF order, then GBPUSD..... And why the compilation is ok and after when the code is running, JForex finds errors....
Thank for your helps !
That's my code: (nothing too long)
package jforex;
import java.util.*;
import com.dukascopy.api.*; import com.dukascopy.api.IEngine.OrderCommand;
public class Test implements IStrategy { private IEngine engine; private IConsole console; private IHistory history; private IContext context; private IIndicators indicators; private IUserInterface userInterface;
@Configurable("Instrument") public Instrument instrument = Instrument.EURUSD;
@Configurable("Period") public Period selectedPeriodo = Period.ONE_MIN;
@Configurable("Period") public Period selectedPeriodc = Period.FIVE_MINS; @Configurable("w") public double w = 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 onAccount(IAccount account) throws JFException { }
public void onMessage(IMessage message) throws JFException { }
public void onStop() throws JFException { }
public void onTick(Instrument instrument, ITick tick) throws JFException { // DEFINITION DU CCI M15 int cciperiod = 14; int shift = 0; double ccim = indicators.cci(instrument, selectedPeriodo, OfferSide.BID, cciperiod, shift);
// DEFINITION DU MACD M5 int fastPeriod = 12; int slowPeriod = 26; int signalPeriod = 9;
double[] macd = indicators.macd(instrument, selectedPeriodc, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, fastPeriod, slowPeriod, signalPeriod, shift); double macdd = macd[1];
// SEND BUY ORDER if (w==0 && ccim>100) {engine.submitOrder("ordreachat", instrument, OrderCommand.BUY, 0.1); w=300;}
// SEND SELL ORDER if (w==0 && ccim <-100) {engine.submitOrder("ordrevente", instrument, OrderCommand.SELL, 0.1); w=400;} // CLOSE BUY ORDER if (w==300 && macdd<0) {engine.getOrder("ordreachat").close(); engine.getOrder("ordreachat").waitForUpdate(IOrder.State.CLOSED); //wait till the order is closed}; w=0; } // CLOSE SELL ORDER if (w==400 && macdd>0) {engine.getOrder("ordrevente").close(); engine.getOrder("ordrevente").waitForUpdate(IOrder.State.CLOSED); //wait till the order is closed}; w=0; } } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { } }
|
|
|
|
 |
popopo
|
Post subject: Re: Strange phenomenun Order send problem with Remote Server |
Post rating: 0
|
Posted: Tue 27 Nov, 2012, 01:20
|
|
User rating: 3
Joined: Mon 05 Mar, 2012, 11:15 Posts: 24 Location: Indonesia, Jakarta
|
You might want to try this public void onTick(Instrument instrument, ITick tick) throws JFException { // need to check what instrument this tick belong to if ( this.instrument != instrument ) { return; } .... // rest of code .... }
|
|
|
|
 |
germain
|
Post subject: Re: Strange phenomenun Order send problem with Remote Server |
Post rating: 0
|
Posted: Tue 27 Nov, 2012, 13:58
|
|
User rating: 0
Joined: Mon 26 Nov, 2012, 16:32 Posts: 11 Location: JapanJapan
|
Thanks for your help !!! But you don't find this weird ??? I precised my instruments, at the begining of the code. How it is possible that my programme decide to change currency pairs like a random function... ???
|
|
|
|
 |
API Support
|
Post subject: Re: Strange phenomenun Order send problem with Remote Server |
Post rating: 0
|
Posted: Tue 27 Nov, 2012, 14:03
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|