Hello,
I’m looking for a way to retrieve the highest and lowest MACD values (the blue line) for each day for the past five days.
Could anyone please help me with that?
There are different ways to do, so could you just define how you want to use them or display them on the chart? So I could suggest the best solution.
I’d like to average these numbers to draw a line on the MACD indicator. The purpose is to know when there seems to be an overreaction to the upside or downside.
Ok and it will be used on intraday timeframes such as 15-minutes for instance?
Yes, that’s correct!
Does that mean the code is dependent on the graph’s timeframe and there is no way to search for data in-between given dates?
Does the graph has to have a 5-day history for the data to be retrieved?
I was thinking of different manner to do it, here is the code that calculate the mean of the last “period” days of highest and lowest MACD values.
period = 5
// ---------------------------
imacd=MACD[12,26,9](close)
once hh = imacd
once ll = imacd
if IntradayBarIndex =0 then
ii=ii+1
$hh[ii]=imacd
$ll[ii]=imacd
endif
$hh[ii]=max(imacd,$hh[ii])
$ll[ii]=min(imacd,$ll[ii])
//mean
if ii>period then
sum = 0
for i = ii downto ii-period do
sum=sum+($hh[i]+$ll[i])/2
next
mean=sum/period
endif
return mean//,$hh[ii],$ll[ii]
Thanks a lot Nicolas!
I’m going to give a try and see if I can tailor it further.
Does the graph have to extend beyond the period (5 days) to calculate the values or can they be calculated independently of the graph’s history length?
Link to above code added as Log 353 here …
Snippet Link Library
The chart must contained the X days history visible.
Is there no way around it?
Can’t we parse historical data even if it’s not on the current graph?
No, the highest and lowest values of an indicator calculated upon a data serie must read it and therefore must be visible on the chart.
Understood, thanks Nicolas!