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.

getting previous values of an indicator wo risking recursion
 Post subject: getting previous values of an indicator wo risking recursion Post rating: 0   New post Posted: Thu 15 Jan, 2009, 21:51 

User rating: 0
Joined: Wed 24 Dec, 2008, 18:49
Posts: 10
I there an easy way to access the previous value of an indicator?
e.g.
1 -the easiest way to compute an exponential moving average , is to take the previous value of the same ema, multiply that by (1-lambda) and add lambda * the current value .
2- if i hold a counter , to count the number of bars since the last true value of a pattern indicator, the easy way is to increment the last value of the counter (unless that pattern is true, so it resets.)

so what i am asking is,
if i am writing a function that will calculate f(x) , and assume that after all the calculation, this function is called on startIndex=endIndex= x,
how can i access f(x-1) easily ?

---

i know i can get the current value (or previous using shift) of a function via the IIndicators interface

IIndicators indicators = context.getIndicators();
indicators.calculateIndicators(....)

but then calling it from within itself risks deep recursion.

___
ok thath last bit was a mistake, but i am leaving it up there for reference.
that is the wrong kind of context.
the IContext interface is available to strategies and not to indicators.
the IIndicatorContext is available to indicators and it doesn't give the getinddicators


 
 Post subject: Re: getting previous values of an indicator wo risking recursion Post rating: 0   New post Posted: Fri 16 Jan, 2009, 09:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
vish wrote:
how can i access f(x-1) easily ?

In current implementation you can't


 

Jump to:  

  © 1998-2024 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