Dukascopy
 
 
Wiki JStore Search Login

Taking the Average of a number of values
 Post subject: Taking the Average of a number of values Post rating: 0   Post Posted: Fri 04 Mar, 2016, 02:50 
User avatar

User rating: 1
Joined: Tue 12 May, 2015, 18:13
Posts: 34
Location: United Kingdom, Headington
say I want to calculate some number X derived from each candle. Is there an easy way to take the average of X for Y[user input] number of candles ?


 
 Post subject: Re: Taking the Average of a number of values Post rating: 0   Post Posted: Mon 07 Mar, 2016, 11:11 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi;

I'm not sure I fully got your idea but you can combine the use of Get historical candles to collect the needed candle data with calculation expression block to perform your maths.
I this is what you're looking for ? any concrete example ?

Thanks


 
 Post subject: Re: Taking the Average of a number of values Post rating: 0   Post Posted: Tue 08 Mar, 2016, 17:03 
User avatar

User rating: 1
Joined: Tue 12 May, 2015, 18:13
Posts: 34
Location: United Kingdom, Headington
Hey Amine , Ill try and give a better example. I need to take the average of a value that I derive from X# of candles that the user defines. Each value to be averages takes the current value and a previous value.

In this example I tried to use a loop with the input being 12 by default. I am (trying to) taking the High-PreviousHigh to get a Difference in the High for each candle in the loop. And then add that to a HighDifference Sum, and then after the loop , divide that by the input value to get an Average of the Difference in the Highs.


Example attached, I doubt it works because it will always recall the same previous candle , instead of the previous candle that would precede the current candle in the array of candles.


Attachments:
File comment: Loops
Looptester.vfs [37.33 KiB]
Downloaded 178 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Taking the Average of a number of values Post rating: 0   Post Posted: Thu 10 Mar, 2016, 11:26 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi,

I see now..
The loop viewer goes through all the candles (12) but the interface will show up only the last value, that's why it is only displaying the last calculation. I need some time to figure out another way to realize your requirement
Beside that there is an error : in the calculation that is plugged at the out of cycle exit(the division) Did you use the "period" as a result on purpose ? cause the the result it generating several errors.

Cheers


 
 Post subject: Re: Taking the Average of a number of values Post rating: 0   Post Posted: Wed 23 Mar, 2016, 14:38 
User avatar

User rating: 1
Joined: Tue 12 May, 2015, 18:13
Posts: 34
Location: United Kingdom, Headington
The period was unintentional , I must have accidently put it in.

The file uploaded was more of illustrational purposes, trying to ask if loops can call upon a candle and a previous candle to create a value


 

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