+1 888 340 6572
MultiCharts Project Management
Go to the previous open issue
Go to the previous issue (open or closed)
Please log in to bookmark issues
Open Bug report MC-759

Apparent bug with AverageFC on Data2

Go to the next issue (open or closed)
Go to the next open issue

I discovered what appears to be a subtle bug when using the AverageFC function in a signal on a multi-data chart. My chart has fifteen-minute bars for SPY as Data1, and daily bars for SPY as Data 2. It uses Data2 to calculate the 100-day moving average, using the following logic:
MA100( 0 ) ;
MA100 = AverageFC( Close, 100 ) of Data2 ; 
This generally works correctly. However, when backtesting, PowerLanguage gives an incorrect result for the MA100 value for the first bar of daily data. In particular, it will calculate the MA100 value for the first day as being about double of what it should be. For subsequent days, it calculates the MA100 correctly. 
Note that the "Maximum Number of Bars..." setting is set to 101, so the problem actually occurs on the 102nd daily bar. I.e., this isn't a problem with AverageFC having insufficient data to calculate the moving average.
I've attached a screenshot. It shows some demonstration code, along with the resulting output in the outupt window. Note that for 7/28/2011, the moving average is calculated incorrectly as 263.70 (twice what it should be), but is calculated correctly as 131.84 for 7/29/2011. It is also calculated correctly for subsequent dates (not shown).
Note that if I use "Average" instead of "AverageFC," the problem goes away. I.e., it only occurs when using series functions.
Also note that it starts the calculations at 16:00 on 7/27/2011, rather than at 09:45 on 7/28/2011. I.e., it starts calculating at the last minute bar of a day, rather than the first minute bar of the next day. Is this the expected behavior, and could this be related to the AverageFC problem?
This isn't urgent -- I can work around this issue for now through some modifications to my code. However, it would be good to resolve this.

Steps to reproduce this issue
  1.  Create a chart that has two data series.  The first instrument should be a 15-minute chart of SPY (or some other instrument) as Data1.  The second instrument should be a 1-day chart of the same instrument as Data2.  Give both series 200 days of back data.
  2.  Add the attached _MATest signal to the chart.  Give the signal a ""Maximum Number of Bars..." setting of 101.
  3.  Observe the results in the output window.  The MA100 value should be incorrect for the first day of calculations, but correct after that date.
  4.  For comparison purposes, try the same code again, but change "AverageFC" to "Average."  This time, the values will be correct.
Comments (1)
user-offline.png  Alex MultiCharts (Alex MultiCharts)
Jan 04, 2012 - 18:09

I am sorry for delay in invesigation of this issue. We will do our best to finish with this as soon as possible.

Issue basics
  • Type of issue
    Bug report
  • Category
    Not determined
  • Targetted for
    MultiCharts 8.0 (RELEASED)
  • Status
  • Priority
    Not determined
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (3)
People involved
  • Posted by
    user-offline.png  Xyzzy (Xyzzy)
  • Owned by
    Not owned by anyone
  • Assigned to
    Not assigned to anyone
  • Subscribers
    1 subscriber(s)
    Click here to show the list of subscribers
Times and dates
  • Posted at
  • Last updated
Issue details
  • Reproducability
    Not determined
  • Severity
Attachments (1)
Commits (0)
There are no code checkins for this issue
Duplicate issues (0)
This issue does not have any duplicates