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.

Manually indicator calculation
 Post subject: Manually indicator calculation Post rating: 0   New post Posted: Sun 23 Oct, 2011, 23:02 

User rating: 0
Joined: Sun 23 Oct, 2011, 22:41
Posts: 24
Location: Ukraine,
Hi all,

Is it possible to calculate indicator for specified array of candles?
For example, I want to calculate SMA(30) for close price. Also, I have array[30] of doubles with close prices. Can I calculate indicator value for this array of prices?

Thank you!


 
 Post subject: Re: Manually indicator calculation Post rating: 0   New post Posted: Mon 24 Oct, 2011, 09:05 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/wiki/index.php ... r_on_array


 
 Post subject: Re: Manually indicator calculation Post rating: 0   New post Posted: Mon 24 Oct, 2011, 11:57 

User rating: 0
Joined: Sun 23 Oct, 2011, 22:41
Posts: 24
Location: Ukraine,
Many thanks for your quick feedback!

Also I have one more question... How can I initialize 'context' or 'indicators' variables without connection to Dukascopy server? As I understand, it's possible, because this code don't use online or historical data from the server.
        IContext context = ???;
        IIndicators indicators = context.getIndicators();
        IIndicator maIndicator = indicators.getIndicator("MA");
        maIndicator.setOptInputParameter(0, 3);
        maIndicator.setOptInputParameter(1, MaType.SMA.ordinal());
        double[] priceArr = new double[]{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1};
        maIndicator.setInputParameter(0, priceArr);
        double[] resultArr = new double[priceArr.length];
        maIndicator.setOutputParameter(0, resultArr);
        maIndicator.calculate(0, priceArr.length - 1);


Thank you!


 
 Post subject: Re: Manually indicator calculation Post rating: 0   New post Posted: Mon 24 Oct, 2011, 12:11 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
BogdanIvaniuk wrote:
Also I have one more question... How can I initialize 'context' or 'indicators' variables without connection to Dukascopy server? As I understand, it's possible, because this code don't use online or historical data from the server.
It does use historical data from the server, since it's a snippet from a strategy (full source code can be found just below the example) and currently the strategies can be ran only in online mode (also when backtesting in Historical Tester).


 
 Post subject: Re: Manually indicator calculation Post rating: 0   New post Posted: Mon 24 Oct, 2011, 12:28 

User rating: 0
Joined: Sun 23 Oct, 2011, 22:41
Posts: 24
Location: Ukraine,
As I understand, there is no way to calculate indicators on own data (stored in array) without connection to Dukascopy? Am I right?
Maybe, exists some way to initialize 'context' variable such as 'IClient client = ClientFactory.getDefaultInstance();' for 'client', but for 'context' by using 'ContextFactory'?
It would be very helpful and would simplify the strategy testing process.


 
 Post subject: Re: Manually indicator calculation Post rating: 0   New post Posted: Mon 24 Oct, 2011, 12:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
BogdanIvaniuk wrote:
As I understand, there is no way to calculate indicators on own data (stored in array) without connection to Dukascopy? Am I right?
In general - it is not supported. But more in particular - it is theoretically possible with indicators which have published source codes and that don't use IHistory. Indicator sources are available in JForex Standalone API in package com.dukascopy.indicators.


 
 Post subject: Re: Manually indicator calculation Post rating: 0   New post Posted: Mon 24 Oct, 2011, 12:51 

User rating: 0
Joined: Sun 23 Oct, 2011, 22:41
Posts: 24
Location: Ukraine,
Thank you for help! I'll look at it.


 

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