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.

Transform IBar into double array
 Post subject: Transform IBar into double array Post rating: 0   New post Posted: Thu 16 Feb, 2012, 10:31 

User rating: 0
Joined: Tue 14 Feb, 2012, 11:24
Posts: 7
Location: Switzerland, ZH
Hallo Support,

as i am new to Java (MATLAB user), is there a way to extract from a list of Historic bar, all the opens/high/low/close into an array?
        // Re-Assign BAR information
        double[] bOpen = (double[]) inputBars[0].getOpen();


inputBars is coming into the calculate method of a custom indicator. Any hint/help would be greatly appreciated!
If i cannot "cast" then i'll have to "loop-it-out" into an array, which looks unpleasent, but it might be fast as well...

Pietro


 
 Post subject: Re: Transform IBar into double array Post rating: 0   New post Posted: Fri 17 Feb, 2012, 09:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
  1. You don't need to cast in this case.
  2. If you use as input type PRICE (https://www.dukascopy.com/client/javadoc ... .Type.html) then you already receive as inputs 4 price arrays and 1 volume array. Consider BullsPowerIndicator as a PRICE usage example (for indicator sources see https://www.dukascopy.com/wiki/#Platform_indicator_source_files)
  3. If using BAR inputs is a necessity then consider the following extraction of values:
    double [][] ohlcArray = new double[4][inputBars.length];
    for (int i = 0; i < inputBars.length; i++){
        ohlcArray[0][i] = inputBars[i].getOpen();
        ohlcArray[1][i] = inputBars[i].getHigh();
        ohlcArray[2][i] = inputBars[i].getLow();
        ohlcArray[3][i] = inputBars[i].getClose();
    }


 

Jump to:  

  © 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