BasicRSI – An example trading system using Welles Wilder’s RSI Indicator

Trading Platform Software for backtesting & auto trading, for stock, futures and forex trading systems Forums Example Trading Systems BasicRSI – An example trading system using Welles Wilder’s RSI Indicator

Tagged: , ,

This topic contains 0 replies, has 1 voice, and was last updated by Seer Seer 8 years, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #635
    Seer
    Seer
    Keymaster

    Wilder’s RSI is a popular oscillator that ranges between zero and 100. Reading’s above 70 indicate the stock is overbought, while readings below 30 indicate the stock is oversold.

    The RSI is oftern used with other indicators, but this example uses the RSI alone.

    Rules:
    Buy when the RSI moves up through 30
    Sell when the RSI moves down through 70

    We have to define two variables to record the fact that the upper and lower RSI bands have been breached. Once they have been breached, we enter/exit when RSI moves back through the band.

    #Basic RSI system
    
    #Define the RSI bands - narrowing the bands will increase trades
    my $upper=70;
    my $lower=30;
    
    #Set the triggers for the bands.
    $TriggerLower=1 if Today(RSI(14))<$lower;
    $TriggerUpper=1 if Today(RSI(14))>$upper;
    
    if (not Position) {
      #We do not have a position - has the trigger fired?
      if ($TriggerLower) {
        if (Today(RSI(14))>$lower) {
          #The RSI has passed up through the lower band, go long.
          BuyOpen;
          #reset the triggers
          $TriggerLower=0;
          $TriggerUpper=0;
        }
      }
    }
    else {
      #We have a position - has the trigger fired?
      if ($TriggerUpper) {
        if (Today(RSI(14))<$upper) {
          #The RSI has passed down through the upper band, close the long.
          SellOpen;
          #reset the triggers
          $TriggerLower=0;
          $TriggerUpper=0;
        }
      }
    }
    • This topic was modified 8 years, 3 months ago by  jez.
    • This topic was modified 8 years, 3 months ago by Seer Seer.
    • This topic was modified 8 years, 3 months ago by Seer Seer.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.