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.

Volume Price Trend
 Post subject: Volume Price Trend Post rating: 1   New post Posted: Mon 02 Mar, 2015, 19:32 
User avatar

User rating: 1
Joined: Tue 01 May, 2012, 22:05
Posts: 17
Location: United Kingdom, London
Hi,

I am trying to make an VPT indicator https://en.wikipedia.org/wiki/Volume%E2%80%93price_trend. My code works when I start the indicator, but when new ticks come in the value is wrong.
I have a variable "value" I keep adding to. If I keep adding once at every new bar, there would be no problem (That is why when Indi starts it is correct). How do I do this?
The value only may add when a new bar is formed (I need the value of the indicator at the "old" bar. But the indicator calculates at every tick so the value gets too big.


 
 Post subject: Re: Volume Price Trend Post rating: 0   New post Posted: Wed 04 Mar, 2015, 12:51 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
In this case it is preferable to set IndicatorInfo.setRecalculateAll(true) for the indicator. It would make sure that all indicator values are recalculated on each calculate call.
In general it is not advisable or necessary to store indicator state between calculate() calls.


 

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