I am just starting out learning how to code with very simple scripts. The code below should trigger a Long Order when the MA20 crosses above the MA50 and sell when the MA20 goes below the MA50. However when backtesting there are a lot of orders that where triggered that shouldn’t have been. Am I doing something obviously wrong?
Moving average crossover
1
2
3
4
5
6
7
8
9
// Conditions to enter long positions// Conditions to enter long positions
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.