I am currently trying to code a strategy that would enter long on a cross of the RSI above its exponential moving average (the "smooth") in the oversold area (below 20), and enter short on a cross of the avg above the RSI in the oversold area (above 80).
The exit strategy for a long position would be on a cross of the smooth above the RSI, and the exit strategy for a short position would be on a cross of the RSI above the smooth.
It sounded like a simple strategy to code in the first place, but now I'm having trouble with the results I get.
With the following code, I get trades firering off on each an every candle, which is really unexpected.
Am I doing something wrong here?
// Short Entry if ( RSI(7, 3)[0] >= 80 && RSI(7, 3).Avg[0] >= 80 && CrossAbove(RSI(7, 3).Avg, RSI(7, 3), 1) ) { EnterShort(DefaultQuantity, ""); } // Long Entry if ( RSI(7, 3)[0] <= 20 && RSI(7, 3).Avg[0] <= 20 && CrossAbove(RSI(7, 3), RSI(7, 3).Avg, 1) ) { EnterLong(DefaultQuantity, ""); } // Short Exit if ( CrossAbove(RSI(7, 3), RSI(7, 3).Avg, 1) ) { ExitShort("", ""); } // Long Exit if ( CrossAbove(RSI(7, 3).Avg, RSI(7, 3), 1) ) { ExitLong("", ""); }
Comment