Help with writing a backtest code with multiple RSI conditions

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #110678 quote
    assafn
    Participant
    Average

    Hello everybody,

    Up until now I always used the “simplified creation”, but for this one I need your help with writing a more specific code:

    To enter a long position the conditions are –

    1. The values of RSI (21) minus RSI (7) should be less than 7

    2. RSI (21) is bigger than RSI (14)

    3. RSI (14) is bigger than RSI (7)

    Thank you

    Assaf

    #110686 quote
    Nicolas
    Keymaster
    Master

    Automated trading questions should be posted in the ProOrder forum section. Please try to write explicit title next time! Many thanks.

    The below code should be ok, I have not tested:

    rsi7=rsi[7]
    rsi21=rsi[21]
    rsi14=rsi[14]
    
    //The values of RSI (21) minus RSI (7) should be less than 7
    c1 = rsi21-rsi7<7
    //RSI (21) is bigger than RSI (14)
    c2 = rsi21>rsi14
    //RSI (14) is bigger than RSI (7)
    c3 = rsi14>rsi7
    
    if c1 and c2 and c3 and not longonmarket then 
     buy 10 contracts at market 
    endif
    #110691 quote
    assafn
    Participant
    Average

    It works!

    Thank you so much!

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

Help with writing a backtest code with multiple RSI conditions


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
assafn @assafn Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by assafn
6 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/21/2019
Status: Active
Attachments: No files
Logo Logo
Loading...