Hi guys,
Trying to get my head round how to get a condition when RSI has been above 75 and is breaking below 70. I can create them independently but can’t see how I can get the RSI above 75 for last x candles…
_rsi = RSI[21](close)
c1 = (_rsi > 75)
c2 = (_rsi CROSSES UNDER 70)
Thanks!
Hi Fredrik! Maybe try with rsi open or high above 75 and then crossing under. The condition is only valid for the last candle.
Hi, thanks, ok wanna guide me? 🙂
_rsi = RSI[21](close) // This is calculating the 21 last bars on the closing prise right?
c1 = _rsi[3](high) // Something like this? rsi high value on the 3:rd candle back in time?
The number in your RSI[14] is referring to the amount of periods used to calculate the RSI value for the LATEST CLOSED candle. As far as I know you can’t use the RSI value from three bars back on your latest bar. However, if you use a very short period to calculate RSI, lets say 2 periods, then you have a greater chance of having the same candle crossing through both the value 75 and 70 at the same time.
I was thinking like this:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM Preloadbars = 100
//indicaator
indicator1 = RSI[2](close)
// Conditions to enter short positions
c1 = (indicator1 CROSSES UNDER 70)
c2 = (high > (indicator1 = 75))
IF c1 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
c2 = (indicator1 CROSSES UNDER 30)
IF c2 THEN
EXITSHORT AT MARKET
ENDIF
Try this code on EURUSD 1 H and you will see. OBS there is no stop loss in place!
Lycka till!