Moving Average Calculation

Questions about MultiCharts and user contributed studies.
Algyros
Posts: 52
Joined: 28 Sep 2009
Location: Austin, TX
Has thanked: 1 time
Been thanked: 5 times

Moving Average Calculation

Postby Algyros » 09 Nov 2009

Is there a way to adjust how moving averages are calculated?

I ask because I'm running some automated strategies using moving average crossovers. The way the strategies have been developed, trades are supposed to be taken when the two moving averages cross when calculated to two places after the decimal point. They are not supposed to be taken when the two moving averages are even to two places after the decimal point.

However, the trades on my strategies are taken when the moving averages are the same to two places after the decimal point. When I zoom in on the moving averages, there has in fact been a cross, but it is clearly based on calculating the moving averages more than two places after the decimal point.

Hence, my question: can I change the way the moving averages are calculated so that no trades are made until there is a crossover when the moving averages are calculated to two places after the decimal point?

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Postby TJ » 09 Nov 2009

can you post some numbers to illustrate your intention?


probably you need to round off some numbers.
look up these keywords:

Round
Mod
Ceiling
Floor
Last edited by TJ on 09 Nov 2009, edited 1 time in total.

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 12 times
Contact:

Postby RobotMan » 09 Nov 2009

32 bit double precision numbers have a lot of decimal places. You probably could use the "round" reserved word (see attached) when calculating the variables that describes the MA.
Attachments
Round.jpg
Round.jpg (15.35 KiB) Viewed 218 times

Algyros
Posts: 52
Joined: 28 Sep 2009
Location: Austin, TX
Has thanked: 1 time
Been thanked: 5 times

Postby Algyros » 09 Nov 2009

Thank you for the replies.

Could you tell me how to use the "round" setting?

Algyros
Posts: 52
Joined: 28 Sep 2009
Location: Austin, TX
Has thanked: 1 time
Been thanked: 5 times

Postby Algyros » 09 Nov 2009

In other words, are these to be added to the study, the signal, or do they go somewhere else? Thank you.

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Postby TJ » 09 Nov 2009


glen demarco
Posts: 35
Joined: 16 Nov 2009
Contact:

Postby glen demarco » 16 Nov 2009

Perhaps if you post a portion of the code (without giving away too much). Sounds like it may be a decimal precision problem.

glen


Return to “MultiCharts”