Hi , i am trying to do and indicator that returns me the summatory of the value (close-open) for the last 10 month but for each month separately, i mean: the last 10 januaries, the last 10 februaries, …..
that is what i did,But it doesn´t work, i don´t know why
Hi, it’s because in the loop, with i+12 instead of i*12 you’re adding all the consecutive months before the one 12 ago instead of “jumping” every 12 months + with 0 to 10 you’re adding that 11 times instead of 9 times to first one to make a total of 10 + you’re counting current candle’s retorno several times inside the loop.
Let’s try with this one to display on a monthly timeframe each month the sum of same-name 10 months as current month + previous same-name 9 one’s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
x=close[0]-open[0]
y=0
Retorno=0
ifbarindex>120then// wanting at least 10 times 12 months in history
fori=1to9do
y=x[i*12]+y// y intermediate calculation of the 9 times before (close-open)
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue