Dear colleagues,
I have a problem with coding an exit for short and long orders with the RSI, or based in the “colour” of the candle.
As part of a system in EUR/USD, I am buying(Long/Short) every time one single candle (in TF: 1h) is bigger than 30 pip size and together with other requirements.
Once the system buy, I want to exit the order, once the first next candle is opposite to the order (i.e.- If I am short, I want the strategy to exit short if the first candle is long and there is an increase in RSI compared to the previous one.
I have tried with the following code but no success whatsoever. I have tried different options and obviously I must be doing something wrong. I am attaching a pic of one operation I can’t solve with my coding.
// Salida Cortos
IF SHORTONMARKET AND (close>open) AND (RSI[2](close)[1]<RSI[2](close)) AND (RSI[2](close)<35) THEN
EXITSHORT AT MARKET
ENDIF
IF SHORTONMARKET AND((open[1]-close[1])>30*pipsize)AND(close>open) THEN
EXITSHORT AT MARKET
ENDIF
Thanks in advance to anyone helping.
Juan
WingParticipant
Veteran
Is this true for the picture you posted?
RSI[2](close)<35
To clarify, you sell short at the end of that red bar, which means position is opened at the open of next bar, and since this bar turns out to be green, you wish to sell at the open of the next bar?
Hi Wing,
yes, you are right. I sell short after the big red candle. The position is open at the beginning of the first green candle, and because the RSI has increased and as precaution I want to exit short at market, so at the opening of the second green candle.
Thanks,
p.s.- yes, it is true. The RSI at the close of the first LONG candle is below 35.