Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

simple questions - select instrument
 Post subject: simple questions - select instrument Post rating: 0   Post Posted: Sun 26 Aug, 2012, 14:27 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
How can I define only one currency in my Strategy? At the moment all currency work, which are open at the bar left
So - I want to apply only EURUSD. Thank you very much. sorry Im a beginner in java. :)


 
 Post subject: Re: simple questions - select instrument Post rating: 1   Post Posted: Sun 26 Aug, 2012, 22:52 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi Demo:

You can use one or more instruments on any strategy if you have the instruments opened on left box. If you don't have any, to your strategy use it/them, you need to subscribe it/them.

If you want your strategy to only react a one or specifc instrument/s you need to filter them.

You can read more information about it here.

I hope that helps.

PS: If you want to learn more about java i have one article where you can find some ways to do this here and on the next ones i do a basic introduction about strategies.

JL


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Mon 27 Aug, 2012, 09:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Mind that the platform not only subscribes to the instruments that you set, but also the ones that are needed for account data calculation, so you also need to filter the bars and ticks that your strategy works with, see:
https://www.dukascopy.com/wiki/#Filter_Ticks_Bars


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Mon 27 Aug, 2012, 17:53 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
Thank you very much for your help
I have tryed in the Strategy as following:

Instrument to use:")
public Instrument myInstrument = Instrument.EURUSD;

public void onTick(Instrument instrument, ITick tick) throws JFException {
if (!instrument.equals(Instrument.EURUSD)) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks

But i receive the following errors:


16:41:55 ----------
16:41:55 Syntax error on token ")", delete this token
16:41:55 ^
16:41:55 if (!instrument.equals(Instrument.EURUSD)) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks
16:41:55 1. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 45)

Whats wrong?
Thank you for your help


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Mon 27 Aug, 2012, 18:53 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi Demo:

You have your first sentences wrong... and have a one more parentisis... the correct one is:

@Configurable("Instrument to use:")
public Instrument myInstrument = Instrument.EURUSD;

public void onTick(Instrument instrument, ITick tick) throws JFException {
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks


If you want not choose other instrument you can remove "@Configurable("Instrument to use:")" line.

Hope that helps.

JL


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Mon 27 Aug, 2012, 19:10 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
Great - thanks for the helpful explanations. I will try it.


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 10:02 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
Hi
It does not work, unfortunately. It opened several currencies still.
Can you help me again. Below is the strategy. Thanks

public Instrument myInstrument = Instrument.EURUSD;

private IContext context = null;
private IEngine engine = null;
private IChart chart = null;
private IHistory history = null;
private IIndicators indicators = null;
private IConsole console = null;
private double volume = 0.02;
private int profitLimit;
private int lossLimit;
private double bidPrice;
private double askPrice;
private double accountEquity;
public Period period = Period.FIVE_MINS;
private Filter indicatorFilter = Filter.NO_FILTER;

public void onStart(IContext context) throws JFException {
Set subscribedInstruments = new HashSet();
subscribedInstruments.add(Instrument.EURUSD);
context.setSubscribedInstruments(subscribedInstruments);
this.context = context;
engine = context.getEngine();
indicators = context.getIndicators();
history = context.getHistory();
console = context.getConsole();
indicators = context.getIndicators();

}

public void onStop() throws JFException {
}

public void onTick(Instrument instrument, ITick tick) throws JFException {
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks
}

protected int positionsTotal(Instrument instrument) throws JFException {
int counter = 0;
for (IOrder order : engine.getOrders(instrument)) {
if (order.getState() == IOrder.State.FILLED) {
counter++;
}
}
return counter;
}

protected String getLabel(Instrument instrument) {
String label = instrument.name();

long time = new java.util.Date().getTime();

label = label.substring(0, 2) + label.substring(3, 5);
label = label + time;
label = label.toLowerCase();
return label;
}

public void onBar(Instrument instrument, Period period, IBar askbar, IBar bidbar) throws JFException {

IBar prevBar = history.getBar(instrument, period, OfferSide.BID, 1);
if(period == Period.FIVE_MINS) {

profitLimit = 20;
lossLimit = 80;


if (askbar.getVolume() == 0) return;


double openPrice = bidbar.getOpen();

askPrice = askbar.getClose();
bidPrice = bidbar.getClose();

double ema = this.indicators.ema(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 34, 0);
double tvs = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 0);
double tvs1 = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 1);

if (positionsTotal(instrument) == 0) {

if (bidPrice > ema && tvs > tvs1 && tvs > 0 && tvs1 < 0) {

buy (instrument, engine, profitLimit, lossLimit, volume);

}

else if (bidPrice < ema && tvs < tvs1 && tvs < 0 && tvs1 > 0) {

sell (instrument, engine, profitLimit, lossLimit, volume);

}
}
}
}


public void onMessage(IMessage message) throws JFException {

if (message != null && message.getType() == IMessage.Type.ORDER_CLOSE_OK) {

IOrder lastOne = message.getOrder();

double profitsLoss = lastOne.getProfitLossInPips();

console.getOut().println("Order : "+lastOne.getLabel()+ " "+ lastOne.getOrderCommand()+ " Pips: "+profitsLoss);


}
}






@Override
public void onAccount(IAccount account) throws JFException {

accountEquity = account.getEquity();



}
public void sell(Instrument instrument, IEngine engine, int takeProfitPipLevel, int endLossPipLevel, double volumeParam) throws JFException {

engine.submitOrder(getLabel(instrument), instrument, IEngine.OrderCommand.SELL, volumeParam, 0, 3, bidPrice
+ instrument.getPipValue() *endLossPipLevel, bidPrice - instrument.getPipValue() * takeProfitPipLevel);
}

public void buy(Instrument instrument, IEngine engine, int takeProfitPipLevel, int endLossPipLevel, double volumeParam) throws JFException {

engine.submitOrder(getLabel(instrument), instrument, IEngine.OrderCommand.BUY, volumeParam, 0, 3, askPrice
- instrument.getPipValue() * endLossPipLevel, askPrice + instrument.getPipValue() * takeProfitPipLevel);
}
}


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 11:13 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi Demo:

You need to do the filter also on onBar method...
Add this line at first line inside the onBar() method:
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks 


Hope that helps

JL


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 13:14 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
Ok - I have done:
public void onStop() throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar)throws JFException {
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks

But i receive the following error:

12:12:28 Duplicate method onBar(Instrument, Period, IBar, IBar) in type koenig
12:12:28 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:12:28 public void onBar(Instrument instrument, Period period, IBar askbar, IBar bidbar) throws JFException {
12:12:28 2. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 71)
12:12:28 ----------
12:12:28 Duplicate method onBar(Instrument, Period, IBar, IBar) in type koenig
12:12:28 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:12:28 public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar)throws JFException {
12:12:28 1. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 42)

I dont know, whats wrong?
Thanks


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 16:35 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi Demo:

You have two "onBar" methods !!!

You can only have one !

The line i say in last post you have to put it on the onBar method you had already in the same way you have done for "onTick" method!

Hope that helps

JL


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 18:27 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
Sorry to say but doesn't work.
I make a mistake somewhere.
find attached the code:
public Instrument myInstrument = Instrument.EURUSD;

private IContext context = null;
private IEngine engine = null;
private IChart chart = null;
private IHistory history = null;
private IIndicators indicators = null;
private IConsole console = null;
private double volume = 0.02;
private int profitLimit;
private int lossLimit;
private double bidPrice;
private double askPrice;
private double accountEquity;
public Period period = Period.FIVE_MINS;
private Filter indicatorFilter = Filter.NO_FILTER;

public void onStart(IContext context) throws JFException {
Set subscribedInstruments = new HashSet();
subscribedInstruments.add(Instrument.EURUSD);
context.setSubscribedInstruments(subscribedInstruments);
this.context = context;
engine = context.getEngine();
indicators = context.getIndicators();
history = context.getHistory();
console = context.getConsole();
indicators = context.getIndicators();

}

public void onStop() throws JFException {
}

public void onTick(Instrument instrument, ITick tick) throws JFException {
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks
}

protected int positionsTotal(Instrument instrument) throws JFException {
int counter = 0;
for (IOrder order : engine.getOrders(instrument)) {
if (order.getState() == IOrder.State.FILLED) {
counter++;
}
}
return counter;
}

protected String getLabel(Instrument instrument) {
String label = instrument.name();

long time = new java.util.Date().getTime();

label = label.substring(0, 2) + label.substring(3, 5);
label = label + time;
label = label.toLowerCase();
return label;
}

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar)throws JFException
if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks
}

IBar prevBar = history.getBar(instrument, period, OfferSide.BID, 1);
if(period == Period.FIVE_MINS) {

profitLimit = 20;
lossLimit = 80;


if (askbar.getVolume() == 0) return;


double openPrice = bidbar.getOpen();

askPrice = askbar.getClose();
bidPrice = bidbar.getClose();

double ema = this.indicators.ema(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 34, 0);
double tvs = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 0);
double tvs1 = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 1);

if (positionsTotal(instrument) == 0) {

if (bidPrice > ema && tvs > tvs1 && tvs > 0 && tvs1 < 0) {

buy (instrument, engine, profitLimit, lossLimit, volume);

}

else if (bidPrice < ema && tvs < tvs1 && tvs < 0 && tvs1 > 0) {

sell (instrument, engine, profitLimit, lossLimit, volume);

}
}
}
}


public void onMessage(IMessage message) throws JFException {

if (message != null && message.getType() == IMessage.Type.ORDER_CLOSE_OK) {

IOrder lastOne = message.getOrder();

double profitsLoss = lastOne.getProfitLossInPips();

console.getOut().println("Order : "+lastOne.getLabel()+ " "+ lastOne.getOrderCommand()+ " Pips: "+profitsLoss);


}
}






@Override
public void onAccount(IAccount account) throws JFException {

accountEquity = account.getEquity();



}
public void sell(Instrument instrument, IEngine engine, int takeProfitPipLevel, int endLossPipLevel, double volumeParam) throws JFException {

engine.submitOrder(getLabel(instrument), instrument, IEngine.OrderCommand.SELL, volumeParam, 0, 3, bidPrice
+ instrument.getPipValue() *endLossPipLevel, bidPrice - instrument.getPipValue() * takeProfitPipLevel);
}

public void buy(Instrument instrument, IEngine engine, int takeProfitPipLevel, int endLossPipLevel, double volumeParam) throws JFException {

engine.submitOrder(getLabel(instrument), instrument, IEngine.OrderCommand.BUY, volumeParam, 0, 3, askPrice
- instrument.getPipValue() * endLossPipLevel, askPrice + instrument.getPipValue() * takeProfitPipLevel);
}
}

and the Error message:

17:23:12 Syntax error on token "(", ; expected
17:23:12 ^
17:23:12 public void onMessage(IMessage message) throws JFException {
17:23:12 16. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 109)
17:23:12 ----------
17:23:12 Syntax error on token "}", delete this token
17:23:12 ^
17:23:12 }
17:23:12 15. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 106)
17:23:12 ----------
17:23:12 instrument cannot be resolved
17:23:12 ^^^^^^^^^^
17:23:12 sell (instrument, engine, profitLimit, lossLimit, volume);
17:23:12 14. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 101)
17:23:12 ----------
17:23:12 instrument cannot be resolved
17:23:12 ^^^^^^^^^^
17:23:12 buy (instrument, engine, profitLimit, lossLimit, volume);
17:23:12 13. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 95)
17:23:12 ----------
17:23:12 instrument cannot be resolved
17:23:12 ^^^^^^^^^^
17:23:12 if (positionsTotal(instrument) == 0) {
17:23:12 12. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 91)
17:23:12 ----------
17:23:12 instrument cannot be resolved
17:23:12 ^^^^^^^^^^
17:23:12 double tvs1 = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 1);
17:23:12 11. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 89)
17:23:12 ----------
17:23:12 instrument cannot be resolved
17:23:12 ^^^^^^^^^^
17:23:12 double tvs = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 0);
17:23:12 10. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 88)
17:23:12 ----------
17:23:12 instrument cannot be resolved
17:23:12 ^^^^^^^^^^
17:23:12 double ema = this.indicators.ema(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 34, 0);
17:23:12 9. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 87)
17:23:12 ----------
17:23:12 bidbar cannot be resolved
17:23:12 ^^^^^^
17:23:12 bidPrice = bidbar.getClose();
17:23:12 8. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 85)
17:23:12 ----------
17:23:12 askbar cannot be resolved
17:23:12 ^^^^^^
17:23:12 askPrice = askbar.getClose();
17:23:12 7. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 84)
17:23:12 ----------
17:23:12 bidbar cannot be resolved
17:23:12 ^^^^^^
17:23:12 double openPrice = bidbar.getOpen();
17:23:12 6. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 82)
17:23:12 ----------
17:23:12 askbar cannot be resolved
17:23:12 ^^^^^^
17:23:12 if (askbar.getVolume() == 0) return;
17:23:12 5. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 79)
17:23:12 ----------
17:23:12 Syntax error on tokens, ConstructorHeaderName expected instead
17:23:12 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:23:12 public void onMessage(IMessage message) throws JFException {
17:23:12 }
17:23:12 }
17:23:12 }
17:23:12 }
17:23:12 sell (instrument, engine, profitLimit, lossLimit, volume);
17:23:12 else if (bidPrice < ema && tvs < tvs1 && tvs < 0 && tvs1 > 0) {
17:23:12 }
17:23:12 buy (instrument, engine, profitLimit, lossLimit, volume);
17:23:12 if (bidPrice > ema && tvs > tvs1 && tvs > 0 && tvs1 < 0) {
17:23:12 if (positionsTotal(instrument) == 0) {
17:23:12 double tvs1 = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 1);
17:23:12 double tvs = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 0);
17:23:12 double ema = this.indicators.ema(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 34, 0);
17:23:12 bidPrice = bidbar.getClose();
17:23:12 askPrice = askbar.getClose();
17:23:12 double openPrice = bidbar.getOpen();
17:23:12 if (askbar.getVolume() == 0) return;
17:23:12 lossLimit = 80;
17:23:12 profitLimit = 20;
17:23:12 if(period == Period.FIVE_MINS) {
17:23:12 4. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 73)
17:23:12 ----------
17:23:12 Syntax error on token ";", { expected after this token
17:23:12 ^
17:23:12 IBar prevBar = history.getBar(instrument, period, OfferSide.BID, 1);
17:23:12 3. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 72)
17:23:12 ----------
17:23:12 instrument cannot be resolved
17:23:12 ^^^^^^^^^^
17:23:12 IBar prevBar = history.getBar(instrument, period, OfferSide.BID, 1);
17:23:12 2. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 72)
17:23:12 ----------
17:23:12 Syntax error on token "JFException", { expected after this token
17:23:12 ^^^^^^^^^^^
17:23:12 public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar)throws JFException
17:23:12 1. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 68)
17:23:12 ----------
17:23:07 Compiling koenig.java
17:21:19 ----------
17:21:19 Syntax error on token "(", ; expected
17:21:19 ^
17:21:19 public void onMessage(IMessage message) throws JFException {
17:21:19 16. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 108)
17:21:19 ----------
17:21:19 Syntax error on token "}", delete this token
17:21:19 ^
17:21:19 }
17:21:19 15. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 105)
17:21:19 ----------
17:21:19 instrument cannot be resolved
17:21:19 ^^^^^^^^^^
17:21:19 sell (instrument, engine, profitLimit, lossLimit, volume);
17:21:19 14. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 100)
17:21:19 ----------
17:21:19 instrument cannot be resolved
17:21:19 ^^^^^^^^^^
17:21:19 buy (instrument, engine, profitLimit, lossLimit, volume);
17:21:19 13. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 94)
17:21:19 ----------
17:21:19 instrument cannot be resolved
17:21:19 ^^^^^^^^^^
17:21:19 if (positionsTotal(instrument) == 0) {
17:21:19 12. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 90)
17:21:19 ----------
17:21:19 instrument cannot be resolved
17:21:19 ^^^^^^^^^^
17:21:19 double tvs1 = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 1);
17:21:19 11. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 88)
17:21:19 ----------
17:21:19 instrument cannot be resolved
17:21:19 ^^^^^^^^^^
17:21:19 double tvs = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 0);
17:21:19 10. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 87)
17:21:19 ----------
17:21:19 instrument cannot be resolved
17:21:19 ^^^^^^^^^^
17:21:19 double ema = this.indicators.ema(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 34, 0);
17:21:19 9. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 86)
17:21:19 ----------
17:21:19 bidbar cannot be resolved
17:21:19 ^^^^^^
17:21:19 bidPrice = bidbar.getClose();
17:21:19 8. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 84)
17:21:19 ----------
17:21:19 askbar cannot be resolved
17:21:19 ^^^^^^
17:21:19 askPrice = askbar.getClose();
17:21:19 7. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 83)
17:21:19 ----------
17:21:19 bidbar cannot be resolved
17:21:19 ^^^^^^
17:21:19 double openPrice = bidbar.getOpen();
17:21:19 6. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 81)
17:21:19 ----------
17:21:19 askbar cannot be resolved
17:21:19 ^^^^^^
17:21:19 if (askbar.getVolume() == 0) return;
17:21:19 5. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 78)
17:21:19 ----------
17:21:19 instrument cannot be resolved
17:21:19 ^^^^^^^^^^
17:21:19 IBar prevBar = history.getBar(instrument, period, OfferSide.BID, 1);
17:21:19 4. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 71)
17:21:19 ----------
17:21:19 Syntax error on token "JFException", { expected after this token
17:21:19 ^^^^^^^^^^^
17:21:19 public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar)throws JFException
17:21:19 3. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 68)
17:21:19 ----------
17:21:19 Syntax error on tokens, ConstructorHeaderName expected instead
17:21:19 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17:21:19 public void onMessage(IMessage message) throws JFException {
17:21:19 }
17:21:19 }
17:21:19 }
17:21:19 }
17:21:19 sell (instrument, engine, profitLimit, lossLimit, volume);
17:21:19 else if (bidPrice < ema && tvs < tvs1 && tvs < 0 && tvs1 > 0) {
17:21:19 }
17:21:19 buy (instrument, engine, profitLimit, lossLimit, volume);
17:21:19 if (bidPrice > ema && tvs > tvs1 && tvs > 0 && tvs1 < 0) {
17:21:19 if (positionsTotal(instrument) == 0) {
17:21:19 double tvs1 = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 1);
17:21:19 double tvs = this.indicators.tvs(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 24, 0);
17:21:19 double ema = this.indicators.ema(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 34, 0);
17:21:19 bidPrice = bidbar.getClose();
17:21:19 askPrice = askbar.getClose();
17:21:19 double openPrice = bidbar.getOpen();
17:21:19 if (askbar.getVolume() == 0) return;
17:21:19 lossLimit = 80;
17:21:19 profitLimit = 20;
17:21:19 if(period == Period.FIVE_MINS) {
17:21:19 IBar prevBar = history.getBar(instrument, period, OfferSide.BID, 1);
17:21:19 }
17:21:19 public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar)throws JFException
17:21:19 if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FIVE_MINS)) return; //filter FIVE_MINS EUR/USD ticks
17:21:19 2. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 67)
17:21:19 ----------
17:21:19 Syntax error on token "}", { expected after this token
17:21:19 ^
17:21:19 }
17:21:19 1. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\compile\koenig.java (at line 66)
17:21:19 ----------

I'm very grateful for the help again


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 18:50 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi Demo:

Are you using a java editor or JForex editor ??

Seems you have some missing parentisis or/and curly brakets on wrong places...

Can you attach the java file ? Is easy that way...

Best regards

JL


 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 19:09 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
:D
Thank you very much. Attached you see the java File


Attachments:
koenig.java [5.06 KiB]
Downloaded 305 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 19:27 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi demo:

You have a curly bracket on wrong position and some variables with wrong names... Remember that java is case sensitive and "askbar" don't is the same as "askBar".
I don't have verified code logic and objectives, only correct errors...

Best regards

JL


Attachments:
koenig.java [5.06 KiB]
Downloaded 307 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: simple questions - select instrument Post rating: 0   Post Posted: Tue 28 Aug, 2012, 20:12 
User avatar

User rating: 0
Joined: Wed 14 Mar, 2012, 19:04
Posts: 46
Location: Switzerland, Kloten
many thanks for the great support. I will test it


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com