Hello everyone,
I introduce myself, my name is Ivan and are currently interested in carrying out research on seasonality.
For this I am interested in creating a indicator that the average price calculations me of a time series in n periods, the chart result should be something like this in image.
Somebody has what idea or has already implemented this type of indicator?
Hi,
>> Please update your country flag in your profile. Thank you 🙂 <<
(see attached file if necessary)
If I remember well, I already came across some kind of seasonal cycle indicator on another website, let me find it and post it here (and please update your profile!).
Ok, here is what I found so far in a German forum in an old topic. This is very nicely done and well coded, I translated the terms to perfectly understand how it works and the calculation and made some modification for display, the indicator come in 2 parts:
- seasonal_oneyear : the purpose of this indicator is to display a previous “startyear” on the chart, overlaid or not on the price. I introduce the “decay” variable to display it over the current year (decay=0) or over the last year period (decay=1). Very useful if you want to know where were the price at the same time, on “startyear” (year 2000 by default set in the parameter)
- seasonal_cycle : this indicator make the loop from “first” year to “last” year for the seasonal cycle computation, it needs “seasonal_oneyear” indicator to run. This is the only one needed to display the seasonal cycle if you only want this information on your chart.
You’ll find both of this files attached, with some screenshots examples.
The first picture show the year 2000 price fluctuation under the current year (decay=0)
The second one display the seasonal cycle calculated from 2000 to 2015 on DAX.
with great respect, the original indicators came from:
http://www.aktienboard.com/forum/f29/prorealtime-cmc-script-programmierung-t94783/262#post2540310
Thanks for the reply,
I can not run the code, I do not validation. audience below so if possible ask for help 🙂
// Variablen (ganze Zahl / >0)
// sJahr = einzelnesJahr = 2000
display = Currentyear - 1
If sJahr <= display Then
Once a = 0
If Year >= sJahr Then
a = a + 1
Endif
If Year = display Then
a = a - 1
c = Close[a]
Else
c = undefined
Endif
diff = (c - c[1]) / c[1]
If Year = display And Year[1] <> display Then
p = 1
linie = 100
Else
p = diff + 1
linie=linie[1] * p
Endif
Else
linie = undefined
Endif
Return linie Coloured(0,0,255) As "einzelnesJahr"
And this the second part:
// Variablen (ganze Zahl / >0)
// v = "von..." = 2000
// b = "bis..." = 2010
t = b - v
z = 0
For i = 1 to t DO
y1 = CALL "mySeasonal_einzeln"[(v+i)-1]
z = z + y1
Next
xx = z / t
If Year >= CurrentYear -1 Then
start = 100
Else
start = undefined
Endif
Return xx Coloured(0,0,260) As "Seasonal", start Coloured(255,0,0) As "100"
That’s why I changed the code, you have to download the files attached to my previous post and use these ones instead of the original topic one.
I understand, can I ask you please let you load your code here that works for you.
I appreciate it, are not very good at programming. If you can thanks 1000 🙂
The first indicator with the changes made in the code below works, what one year:
// variables (integer / >0)
// year = single year = 2000
display = Currentyear - 0
If year <= display Then
Once a = 0
If Year >= year Then
a = a + 1
Endif
If Year = display Then
a = a - 1
c = Close[a]
Else
c = undefined
Endif
diff = (c - c[1]) / c[1]
If Year = display And Year[1] <> display Then
p = 1
linie = 100
Else
p = diff + 1
linie=linie[1] * p
Endif
Else
linie = undefined
Endif
Return linie Coloured(0,0,255) As "single year"
The second still not, it gives me the error picture attached:
// Variables (integer / >0)
// v = "from..." = 2000
// b = "to..." = 2016
t = b - v
z = 0
For i = 1 to t DO
y1 = CALL "Seasonal 1 Year"[(v+i)-1]
z = z + y1
Next
xx = z / t
If Year >= CurrentYear -1 Then
start = 100
Else
start = undefined
Endif
Return xx Coloured(0,0,260) As "Seasonal", start Coloured(255,0,0) As "100"
the wording is:
Syntax error:
define the variable b
define the variable v
It seems to me that in the code are defined :/