@Tomasz Thank you for the clarification why it is not a good idea to enter negative prices. Much appreciated
@portfoliobuilder
Yes, I have been trying to calculate the Weekly NHNL . I have used the following code, which is similar to yours, but it does not chart properly.
 // NHNL Data from BarChart.com
US12M_NHNL = Foreign("&NHNL_12M_NH","Close")-Foreign("&NHNL_12M_NL","Close");
NHNLWeekly = Sum(US12M_NHNL,5);
Plot(NHNLWeekly,"NHNL_Weekly",colorRed,styleline);
The last 5 days NHNL (New Highs - New Lows) from Barchart.com are as following:
16.03; 1-2678 = -2677
17.03; 14-1767 = -1753
18.03; 17-2414 = -2397
19.03; 14-1134 = -1120
20..03; 4-507 = -503
So the Weekly (5 day rolling sum) value is -2677-1753-2397-1120-503 = -8450
On the Daily chart it is correct but on the Weekly chart I can not get it to plot correctly . The Weekly chart shows a value of -3854 and I have no idea where that value comes from, see charts below.


I tried with your formula (many thanks for writing that) and I get the same chart results as above.
After reading about AddtoComposites and trying a few things I finally found a solution with the AddtoComposites using following formula, Just need to run scan to calculate the result.
 // NHNL Data from BarChart.com
US12M_NHNL = Foreign("&NHNL_12M_NH","Close")-Foreign("&NHNL_12M_NL","Close");
NHNLWeekly = Sum(US12M_NHNL,5);
AddToComposite(NHNLWeekly,"&NHNL_Weekly","X");
Plot(Foreign("&NHNL_Weekly","C",1),"US_Weekly_NHNL",colorRed,styleline);
PlotGrid(0,colorBlack);
PlotGrid(-4000,colorAqua);

Thank you all for the help.