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.

Limit calculated bars in histogram of indicator
 Post subject: Limit calculated bars in histogram of indicator Post rating: 0   New post Posted: Mon 11 May, 2015, 16:30 
User avatar

User rating: 0
Joined: Mon 16 Jun, 2014, 06:30
Posts: 18
Location: Latvia,
Hello!

Because of my own developed indicator complicity, performance is not great. How to limit calculated bars qnt-y? By default it process 10.000 bars. I need just 100.

Thank you.


 
 Post subject: Re: Limit calculated bars in histogram of indicator Post rating: 0   New post Posted: Wed 27 May, 2015, 12:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
One can just set to Double.NaN first 9900 elements in output array and calculate values only for 100 last elements.
   
public IndicatorResult calculate(int startIndex, int endIndex) {
   int i, j;
   for (i = startIndex, j = 0; i <= endIndex; i++, j++) {
      if (endIndex - i >= 100) {
         outputs[0][j] = Double.NaN;
      } else {
         // complex calculations
         outputs[0][j] = ...;
      }
   }
   return new IndicatorResult(startIndex, j);
}


 

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