RSI Code very simple but effective

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #73661 quote
    rmhandel
    Participant
    Junior

    Maybe somebody is interested in this code:

    hello I would like to receive support/help with the following code. He is very simple but I do not know exactly how I accomplish this:

    I buy at RSI> 35 and sell when RSI undercuts the 70s line. Attention not when he crosses but after it is over it and leaves them again only.

    i can code the crosses but not the keeping over the 70s line.

    Thanks for your efforts.

    Robert
    rmhandel

    #73666 quote
    Eric
    Participant
    Master

    ?

    rsi > 70 previous period and rsi < 70 current period?

    #73668 quote
    rmhandel
    Participant
    Junior

    yes it keeps above RSI > 70 the entire time. Because it raise above this line,  and sells when RSI < 70 current period

    #73676 quote
    Vonasi
    Moderator
    Master

    Eric was giving you your answer:

    c1 = RSI[14](close[1]) > 70 and RSI[14](close[0]) < 70
    
    IF c1 then
    Sell at market
    endif
    rmhandel thanked this post
    #73678 quote
    rmhandel
    Participant
    Junior

    many thanks  i am going to try it and will give you feedback.

    #73738 quote
    rmhandel
    Participant
    Junior

    hi, unfortunately it is not working.

    The results of your code are same like this:

    // Festlegen der Code-Parameter
    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    
    // Bedingungen zum Einstieg in Long-Positionen
    indicator1 = RSI[14](close)
    c1 = (indicator1 > 35)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Bedingungen zum Ausstieg von Long-Positionen
    indicator2 = RSI[14](close)
    c2 = (indicator2 CROSSES UNDER 70)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Stops und Targets
    #73747 quote
    robertogozzi
    Moderator
    Master

    To write code, please use the <> “insert PRT code” button, to make code easier to read.

    #73748 quote
    robertogozzi
    Moderator
    Master

    There’s no need to tell your strategy to stay on market WHILE Rsi > 70, since you ordered to SELL only when it crosses UNDER 70, so it opens a LONG trade, then stay on market till RSI goes above 70 and will close the trade only when it CROSSES UNDER, isn’t that what you want?

    Nicolas thanked this post
    #73771 quote
    Nicolas
    Keymaster
    Master

    stay on market till RSI goes above 70 and will close the trade only when it CROSSES UNDER, isn’t that what you want?

    I understood exactly the same thing and the code looks ok to me.

    #73775 quote
    rmhandel
    Participant
    Junior

    yes this is what i wanted. But it don´t works so. The point is i want to stay long in market even the RSI is over 70 and quite time it is above it.

    And at least i want to sell and close position when RSI is under 70 . Maybe i can post my ready code here if you want to test it in pro order somebody.

    so we would better understand over the coding.

    #73777 quote
    rmhandel
    Participant
    Junior

     

    //-------------------------------------------------------------------------
    // Hauptcode : über 70 bleibt und kreuzt 70
    //-------------------------------------------------------------------------
    // Festlegen der Code-Parameter
    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    
    // Bedingungen zum Einstieg in Long-Positionen
    indicator1 = RSI[14](close)
    c1 = (indicator1 CROSSES OVER 68)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Bedingungen zum Ausstieg von Long-Positionen
    indicator2 = RSI[14](close)
    c2 = (indicator2[2] > 70)
    indicator3 = RSI[14](close)
    c3 = (indicator3 CROSSES UNDER 70)
    
    IF c2 AND c3 THEN
    SELL AT MARKET
    ENDIF
    #73778 quote
    robertogozzi
    Moderator
    Master

    As I said before, I tested your code AS IS and it works.

    Are you using the same RSI on screen, or do you have different settings other than 14?

    Can you attach any screenshot with all details of when it did not work?

    #73779 quote
    robertogozzi
    Moderator
    Master

    I was writing while you posted your new code.

    It’s different from the first one, which one is the good one?

    They do different things, the latter buys when a CROSSOVER 68 occurs, while the original when price was > 35. It sells when there is a CROSSDUNDER 70 AND the two previous candles were above 70, while the original one only on CROSSUNDER.

    I am asking ahaint, what do you exactly want?

    Moreover, please use INSERT PRT button to enter code. Thanks.

    #73780 quote
    robertogozzi
    Moderator
    Master

    Again, not ahaint… sorry!

    #73785 quote
    Nicolas
    Keymaster
    Master

    The last posted code by rmhandel cannot work as c2 and c3 can’t be true at the same time.

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

RSI Code very simple but effective


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rmhandel @rmhandel Participant
Summary

This topic contains 19 replies,
has 5 voices, and was last updated by rmhandel
7 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/19/2018
Status: Active
Attachments: No files
Logo Logo
Loading...