Hi,
Could you please help me to modify slightly standard RSI Strategy to include not 2 inputs but 3 inputs ( input over_bought = 70, input_neutral=50, input over_sold = 30) and to allow only one trade since crossover.
Buy only once if RSI crosses above any of these 3 levels and Sell only once when RSI crosses below any of these 3 levels .
In other words, you stay in long position without crossing below any intermediate levels ( 30, 50, 70), but reverse the position immediately if price crosses below any of these 3 levels ( 30, 50, 70) and vice versa.
I can not figure out how to script this condition.
Thanks in advance.
Could you please help me to modify slightly standard RSI Strategy to include not 2 inputs but 3 inputs ( input over_bought = 70, input_neutral=50, input over_sold = 30) and to allow only one trade since crossover.
Buy only once if RSI crosses above any of these 3 levels and Sell only once when RSI crosses below any of these 3 levels .
In other words, you stay in long position without crossing below any intermediate levels ( 30, 50, 70), but reverse the position immediately if price crosses below any of these 3 levels ( 30, 50, 70) and vice versa.
I can not figure out how to script this condition.
Thanks in advance.
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2013-2020
#
input price = close;
input length = 14;
input over_bought = 70;
input over_sold = 30;
input rsiAverageType = AverageType.WILDERS;
def rsi = reference RSI(price = price, length = length, averageType = rsiAverageType);
AddOrder(OrderType.BUY_AUTO, rsi crosses above over_sold, tickColor = GetColor(0), arrowColor = GetColor(0), name = "RSI_LE");
AddOrder(OrderType.SELL_AUTO, rsi crosses below over_bought, tickColor = GetColor(1), arrowColor = GetColor(1), name = "RSI_SE");
Last edited by a moderator: