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?
Moving Average Calculation
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
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
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.
- RobotMan
- Posts: 375
- Joined: 12 Jul 2006
- Location: Los Altos, California, USA
- Has thanked: 31 times
- Been thanked: 13 times
- Contact:
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
- (15.35 KiB) Downloaded 550 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
-
- Posts: 35
- Joined: 16 Nov 2009
- Contact: