+1 888 340 6572
Closed Feature request MC-2050

# Possible BUG or different interpretation between MC a TS

This issue has been closed with status "Declined" and resolution "Not determined".
Description

I wanted to move a system developed in TS to MC....
So I exported and reimported. Applied on same exact datafeed.
I was having different results so I went into all possible details and debug and found a difference which I am not sure can be considered a bug of MC or TS ... but for sure it is something different which can drive several traders crazy.
My system uses the standard function detrend... both in MC and TS this function is present and readonly. The content is different in term of syntax but same in term of calculations.
Here the analysys:

## Detrend function in TS:

inputs:
variables: Offset( 0 ) ;
Offset = Length * .5 + 1 ;

## Detrend = Price - Average( Price, Length )[Offset] ;

assume input len 3'¦ and O in price'¦
offset will be (3*0.5)+1 so 2.5!!!!
applied in Detrend = Price - Average( Price, Length )[2.5] ;

Here the BIG difference:
TS will consider Offset of [2] '¦
MC will consider Offset of [3] '¦
How i discovered this:

## I created than a customized detrend function'¦

inputs:
variables: Offset( 0 ) ;
Offset = Length * .5 + 1 ;
if date = 1060921 then print("detrend with 2 ", Price - Average( Price, Length )[2]:0:10);
if date = 1060921 then print("detrend with 3 ", Price - Average( Price, Length )[3]:0:10);
Detrend_pers = Price - Average( Price, Length )[Offset] ;

## if date = 1060921 then print("detrend with variable ", Price - Average( Price, Length )[Offset]:0:10);

applied to same trading system in TS and MC '¦ and got these results in printout
MC:
detrend with 2 0.3489583333
detrend with 3 0.2473958333
detrend with variable 0.2473958333
TS:
detrend with 2 0.3489583333
detrend with 3 0.2473958333
detrend with variable 0.3489583333
So it is clear that MC and TS uses a decimal value in a different way as offset.

## To solve the issue I have than made a new detrend function and introduced a intportion

inputs:
variables: Offset( 0 ) ;
Offset = intportion( Length * .5 + 1 );

## Detrend_pers = Price - Average( Price, Length )[Offset] ;

Now both systems act in the same way.
As I said it's not a bug but it's a different way to interpret the same issue.
I suggest MC to adjust the behaviour to TS... at least the result will be the same.

Steps to reproduce this issue

floow what described before

#1
MultiCharts Support (MultiCharts)
Aug 09, 2017 - 00:47
The reason is close2.5 returns 3 bars back, while it is 2 bars back in TS. So, this is different approach of the platforms for rounding. The code of the function is opened and can be modified and the workaround that you mentioned should help in this case.
History
Issue basics
User pain
• Type of bug
Not triaged
• Likelihood
Not triaged
• Effect
Not triaged
Affected by this issue (2)
People involved
Times and dates
• Posted at
• Last updated
Issue details
• Resolution
Not determined
• Severity
Normal
Attachments (0)
There is nothing attached to this issue
Commits (0)
There are no code checkins for this issue
Duplicate issues (0)
This issue does not have any duplicates