|
JFOREX-3410 Timed entry |
jozsi74
|
Post subject: JFOREX-3410 Timed entry |
Post rating: 0
|
Posted: Thu 15 Dec, 2011, 09:53
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
But my problem that the XAUUSD Daily chart is not working. Lot of data is missing from the chart, however few days ago it was fine. See the attached file. What's the matter?
Attachments: |
xauusd.JPG [162.47 KiB]
Downloaded 501 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.
|
|
|
|
|
 |
API Support
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Fri 23 Dec, 2011, 18:52
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
jozsi74
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Tue 27 Dec, 2011, 16:38
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
Thanks. Today I noticed the same problem with XAGUSD Daily.
|
|
|
|
 |
jozsi74
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Tue 27 Dec, 2011, 17:16
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
Can you help me to modify the strategy to work on Range bars instead of time period?
|
|
|
|
 |
API Support
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Wed 28 Dec, 2011, 12:01
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
jozsi74 wrote: Can you help me to modify the strategy to work on Range bars instead of time period? See the following strategy: package jforex.strategies;
import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue;
import com.dukascopy.api.*; import com.dukascopy.api.IEngine.OrderCommand; import com.dukascopy.api.bar.IRangeBar; import com.dukascopy.api.listener.IRangeBarFeedListener;
/** * The strategy makes a BUY order on completion of a GREEN candle * and SELL - on RED one. * * The user can select if the strategy works with: * a) candle stick bars (time period), * b) range bars (price range). * */
@RequiresFullAccess public class TradeOnDirectionRangeBars implements IStrategy {
@Configurable("Use range bars") public boolean useRangeBars = true; @Configurable("Instrument") public Instrument instrument = Instrument.EURUSD; @Configurable("Period (used only with candles)") public Period period = Period.TEN_SECS; @Configurable("Price range (used only with range bars)") public int priceRangePips = 1; @Configurable("Amount") public double amount = 0.001; @Configurable("Stop loss") public int stopLossPips = 3; @Configurable("Take profit") public int takeProfitPips = 5;
private IEngine engine; private IConsole console; private IHistory history; private int orderCount; private IRangeBar prevRangeBar; private Queue<OrderCommand> orderCmds = new ConcurrentLinkedQueue<OrderCommand>(); @Override public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory();
console.getOut().println("start"); context.subscribeToRangeBarFeed(Instrument.EURUSD, OfferSide.BID, PriceRange.valueOf(priceRangePips), new IRangeBarFeedListener() { public void onBar(Instrument instrument, OfferSide offerSide, PriceRange priceRange, IRangeBar bar) { if(!useRangeBars){ return; }
if(prevRangeBar == null){ prevRangeBar = bar; return; }
//add order command to queue - we can submit order only from strategy thread try { OrderCommand cmd = getCommand(bar, prevRangeBar); orderCmds.offer(cmd); } catch (JFException e) { e.printStackTrace(console.getErr()); } prevRangeBar = bar; } }); }
@Override public void onTick(Instrument instrument, ITick tick) throws JFException { if(!useRangeBars){ return; } //execute all order commands made in range bar feed while(!orderCmds.isEmpty()){ submitOrder(orderCmds.poll()); } }
@Override public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if(useRangeBars){ return; } if( this.instrument != instrument || this.period != period){ return; } //take previous bar from historical data IBar prevCandleStickBar = history.getBar(instrument, period, OfferSide.BID, 2); OrderCommand cmd = getCommand(bidBar, prevCandleStickBar); submitOrder(cmd); } private OrderCommand getCommand(IBar curBar, IBar prevBar) throws JFException{ return curBar.getClose() > prevBar.getClose() ? OrderCommand.BUY : OrderCommand.SELL; } private IOrder submitOrder(OrderCommand orderCmd) throws JFException {
double stopLossPrice, takeProfitPrice;
// Calculating stop loss and take profit prices if (orderCmd == OrderCommand.BUY) { stopLossPrice = history.getLastTick(this.instrument).getBid() - getPipPrice(this.stopLossPips); takeProfitPrice = history.getLastTick(this.instrument).getBid() + getPipPrice(this.takeProfitPips); } else { stopLossPrice = history.getLastTick(this.instrument).getAsk() + getPipPrice(this.stopLossPips); takeProfitPrice = history.getLastTick(this.instrument).getAsk() - getPipPrice(this.takeProfitPips); }
// Submitting an order for the specified instrument at the current market price return engine.submitOrder("order" + ++orderCount, this.instrument, orderCmd, this.amount, 0, 5, stopLossPrice, takeProfitPrice); } private double getPipPrice(int pips) { return pips * this.instrument.getPipValue(); }
@Override public void onMessage(IMessage message) throws JFException { //if the message is related to order print its content if (message.getOrder() != null){ console.getOut().println(message.getOrder().getLabel() + " " + message.getType() + " " + message.getContent()); } }
@Override public void onAccount(IAccount account) throws JFException {
}
@Override public void onStop() throws JFException { //close all orders on strategy stop for(IOrder o : engine.getOrders()){ o.close(); } }
}
Attachments: |
TradeOnDirectionRangeBars.java [4.5 KiB]
Downloaded 394 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.
|
|
|
|
|
 |
jozsi74
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Wed 28 Dec, 2011, 14:00
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
Thanks! Working fine. I am testing lot of things and if there is a problem I'll write it.
|
|
|
|
 |
jozsi74
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Thu 29 Dec, 2011, 07:46
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
I noticed that when I am using range bars the bars are not following the price. I try to explain what do I mean. When I am checking time bars then the bars movement is following the price exactly. I can see the same price on the top left corner and on the bars. But when I am checking range bars, then they are not moving, however the price is changing. See the attached picture. Notice the price is very different on the top left corner and on the right side. So the bars are not following the price change. What's wrong?
Attachments: |
d1.JPG [141 KiB]
Downloaded 473 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.
|
|
|
|
|
 |
jozsi74
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Thu 29 Dec, 2011, 12:54
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
I attach a charts, it looks crocked for me. You can see 2 green bars on the middle and they look double. I do not understand how did they come? Most of the range bar charts are similar, lot of bars look very strange, not fitting into the chart. Anything is wrong or I do not understand it?
Attachments: |
c1.JPG [154.62 KiB]
Downloaded 510 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.
|
|
|
|
|
 |
API Support
|
Post subject: Re: Timed entry |
Post rating: 0
|
Posted: Thu 29 Dec, 2011, 13:44
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
This will be fixed with the next release of JForex client.
|
|
|
|
 |
jozsi74
|
Post subject: Re: JFOREX-3410 Timed entry |
Post rating: 0
|
Posted: Thu 09 Feb, 2012, 11:08
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
I wanted to try the strategy - TradeOnDirectionRangeBars but it is not working now. Currently I am using Dukascopy 2.14.22.2 JForex API 2.6.57 How to modify the strategy?
|
|
|
|
 |
API Support
|
Post subject: Re: JFOREX-3410 Timed entry |
Post rating: 0
|
Posted: Thu 09 Feb, 2012, 11:58
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
change import com.dukascopy.api.bar.IRangeBar; import com.dukascopy.api.listener.IRangeBarFeedListener; to import com.dukascopy.api.feed.*;
|
|
|
|
 |
jozsi74
|
Post subject: Re: JFOREX-3410 Timed entry |
Post rating: 0
|
Posted: Thu 09 Feb, 2012, 12:11
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
Now I can compile, it is OK. But when I run a historical test and set up range bar, then it is not doing anything. The time is just running, but no action. It reaches the console.getOut().println("start"); but after that I don't know what's happening. If I am using the time based bars, then it is running well. So what's wrong with the range bar? Where is the problem in the code?
|
|
|
|
 |
jozsi74
|
Post subject: Re: JFOREX-3410 Timed entry |
Post rating: 0
|
Posted: Wed 22 Feb, 2012, 09:10
|
|
User rating: 0
Joined: Tue 11 Oct, 2011, 20:13 Posts: 64 Location: India,
|
I am using 2.6.58 I am trying with more instruments, pips, but it is not working.
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|