Setting Exit Short/Long orders with RSI

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #42035 quote
    Juan Salas
    Participant
    Master

    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.

    Screen-Shot-2017-07-30-at-23.05.35.png Screen-Shot-2017-07-30-at-23.05.35.png
    #42037 quote
    Juan Salas
    Participant
    Master
    // 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
    #42038 quote
    Juan Salas
    Participant
    Master

    Thanks in advance to anyone helping.

    Juan

    #42042 quote
    Wing
    Participant
    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?

    #42047 quote
    Juan Salas
    Participant
    Master

    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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Setting Exit Short/Long orders with RSI


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Juan Salas @juan-salas Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Juan Salas
8 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/30/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...