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.

Filling Array with UltOsc Values
 Post subject: Filling Array with UltOsc Values Post rating: 0   New post Posted: Tue 17 May, 2011, 16:33 

User rating: 0
Joined: Tue 17 May, 2011, 16:31
Posts: 1
Location: ZA
Hey everyone,

I'm struggling with filling an array with UltOsc indicator values. Here is my code:

   

int OscPeriod = 14;
double[] OscVal = new double[OscPeriod];

IBar bidBar = this.history.getBar(instrument, period, OfferSide.BID, 1);
   
OscVal = this.indicators.ultOsc(instrument, period, OfferSide.BID, UltOsc1, UltOsc2, UltOsc3, Filter.NO_FILTER, OscPeriod, bidBar.getTime(), 0);



Eclipse does not show any problem, but the code does not work and if I cancel a back test the program totally freezes and I have to do a force close and restart the apllication.

Any help will be appreciated!


 
 Post subject: Re: Filling Array with UltOsc Values Post rating: 0   New post Posted: Thu 19 May, 2011, 16:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider the following onBar method:
 @Configurable("Period")
 public Period period = Period.TEN_SECS;
 @Override
 public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {

  if (!instrument.equals(Instrument.EURUSD) || !period.equals(this.period))
   return;

  String DATE_FORMAT_NOW = "HH:mm:ss"; // "yyyy-MM-dd HH:mm:ss";
  SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
  sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

  int OscPeriod = 14;
  int UltOsc1 = 7;
  int UltOsc2 = 14;
  int UltOsc3 = 28;

  double[] OscVal = this.indicators.ultOsc(instrument, period, OfferSide.BID, UltOsc1, UltOsc2, UltOsc3,
   Filter.NO_FILTER, OscPeriod, bidBar.getTime(), 0);

  console.getOut().println(sdf.format(bidBar.getTime()) + " - ultOsc array: " + arrayToString(OscVal));

 }

 private static String arrayToString(double[] arr) {
  String str = "";
  for (int r = 0; r < arr.length; r++) {
   str += " " + (new DecimalFormat("#.#######")).format(arr[r]) + "; ";
  }
  return str;
 }


Note that the most recent ultOsc value is the last element in the OscVal array.


 

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