Hello, I use this code:
p1=ref(c,-1);p2=C;ret=(p2-p1)/p1; AddToComposite(ret,"~MKT","C"); AddToComposite(1 ,"~MKT","V"); N=Foreign("~MKT","V"); SumMkt=Foreign("~MKT","C"); RetMkt=SumMkt/N; When I run scan I use an appropriate reference symbol, and I keep the same symbol as the active one. This works fine in daily time frame but with weeks or months I get ~mkt disalligned from the reference. For example weeks for ~mkt start 2 days earlier. the consequence is that using retmkt in formulas gives me empty. I always use the same time interval in the chart and in the periodicity in AA window. Please note that ~mkt cannot be obtained by simply compressing daily ~mkt data to weekly changing time frame in the chart, as you can easily see from its definition, but has to be obtained by running scan every for each different time frame. Any suggestion on how to fix this ? Thanks Ly