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.

Newcomer to Java, want to create a similar strategy to the one on the JForex wiki
 Post subject: Newcomer to Java, want to create a similar strategy to the one on the JForex wiki Post rating: 0   New post Posted: Tue 21 Jun, 2016, 07:33 
User avatar

User rating: 0
Joined: Wed 23 Mar, 2016, 21:17
Posts: 7
Location: Czech RepublicCzech Republic
Good morning, I would like to create a strategy that is very similar to the ones that are on the JForex wiki site as a starter, so that it will be easier than starting out something completely new on my own.

I am a newcomer to Java but I do have some knowledge of C#, and I saw there are some similarities. I would however like to ask the following questions:

1) Can I make the simple SMA crossover strategy on the wiki work for example on range bar charts? If yes should I specify a pip range?

2) Are JForex strategies generally only one class that implements the required interfaces?

3) Do I need a certain IDE to develop this strategy? Is there autocomplete on the code or should I be looking at what's available on the wiki?

4) After I've created the strategy, is it something I can immediately insert to JForex?

Thank you in advance


 
 Post subject: Re: Newcomer to Java, want to create a similar strategy to the one on the JForex wiki Post rating: 0   New post Posted: Tue 21 Jun, 2016, 14:00 
User avatar

User rating: 0
Joined: Wed 23 Mar, 2016, 21:17
Posts: 7
Location: Czech RepublicCzech Republic
Ok, so I wanted to say that Ihave had some time to delve into the wiki, and some of my questions have been answered. I apologize for asking them here. Some questions however still remain, for example I still don't know if I can get a strategy to work on a range bar chart, and set its pip size.

Also another questions that I still have even after looking through the wiki, and the IContext object, is that I'm not sure if I can get the current instrument price. I've noticed most strategies use the last bar information, but what if I wanted to get current price to use in the OnTick method? Is it possible?


 
 Post subject: Re: Newcomer to Java, want to create a similar strategy to the one on the JForex wiki Post rating: 0   New post Posted: Wed 22 Jun, 2016, 13:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Example for subscribing to range bars is given in SingleSimpleFeedTest.java available from:
https://www.dukascopy.com/wiki/#Chart_feeds

The following code could be used to get the values of currently forming price range bar
public void onTick(Instrument instrument, ITick tick) throws JFException {
   IFeedDescriptor rangeBarFeedDescriptor =     
      new RangeBarFeedDescriptor(
         Instrument.EURUSD,
         PriceRange.TWO_PIPS,
         OfferSide.ASK
      );   

   IRangeBar rangeBar = (IRangeBar) history.getFeedData(rangeBarFeedDescriptor, 0);
   console.getOut().println(rangeBar);
}


 
 Post subject: Re: Newcomer to Java, want to create a similar strategy to the one on the JForex wiki Post rating: 0   New post Posted: Wed 22 Jun, 2016, 17:23 
User avatar

User rating: 0
Joined: Wed 23 Mar, 2016, 21:17
Posts: 7
Location: Czech RepublicCzech Republic
API Support wrote:
Example for subscribing to range bars is given in SingleSimpleFeedTest.java available from:
https://www.dukascopy.com/wiki/#Chart_feeds

The following code could be used to get the values of currently forming price range bar
public void onTick(Instrument instrument, ITick tick) throws JFException {
   IFeedDescriptor rangeBarFeedDescriptor =     
      new RangeBarFeedDescriptor(
         Instrument.EURUSD,
         PriceRange.TWO_PIPS,
         OfferSide.ASK
      );   

   IRangeBar rangeBar = (IRangeBar) history.getFeedData(rangeBarFeedDescriptor, 0);
   console.getOut().println(rangeBar);
}


Thank you. May I ask what the difference is between the OnFeedData method and the OnTick method?

If I wanted to implement the Crossover strategy that is on this webpage: https://www.dukascopy.com/wiki/#Strategy_Tutorial
but for another type of chart, would I have to only change the feed?


 
 Post subject: Re: Newcomer to Java, want to create a similar strategy to the one on the JForex wiki Post rating: 0   New post Posted: Mon 27 Jun, 2016, 08:12 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
onTick is called when a new tick is created, all ticks have this method.
onFeedData is used to receive data from custom bars. onFeedData belongs to a separate interface IFeedListener and it is only called when subscribed by IContext.subscribeToFeed,


 

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