Trading with RSI indicator involves the following signals:
• RSI moving above 50 level — uptrend is confirmed, below 50 — downtrend is confirmed.
• RSI peaking above 70 level — market is overbought.
• RSI staying above 70 level — uptrend is running strong.
• RSI exiting 70 level — downtrend is underway, or at least a correction down is due. (Opposite for RSI falling below 30.)
• RSI trend line breakout - early warning about chart trend line breakout.
• RSI diverging from price on the chart — an early warning of a possible trend change.
How to trade with RSI indicator
RSI indicator is often referred as an overbought/oversold indicator, however, this is not exactly accurate. RSI doesn't provide Buy/Sell signals upon reaching oversold/overbought areas, there are certain rules, which help to identify the right timing for entries and exits.
Readings above 70 indicate an overbought market, while readings below 30 indicate an oversold market.
However, once RSI advances above 70 it is not yet a signal for an immediate Selling, since RSI may stay in overbought area for a long-long time. In fact, when a strong uptrend develops, readings above 70 are just a beginning of a great upward move; an opposite is true for a downtrend and readings below 30.
In order to enter at the right moment (on the true market reversal) Forex traders should wait for RSI to leave its overbought/oversold area. For example, when RSI goes above 70, Forex traders would prepare to Sell, but the actual trade will take place only when RSI crosses down below 70.
Opposite true for an oversold RSI: once RSI goes below 30, traders wait for the indicator to come out of an oversold area and rise above 30 before placing a Buy order.
Forex traders also use 50 level of the RSI indicator, which separates buying forces from selling forces on the market. Certain trading strategies use RSI 50 level to confirm Long and Short entries by looking at a positioning of the RSI in relation to its 50 level.
RSI indicator has got another handy feature: Forex traders use RSI to draw trend lines.
While RSI's trend line stays intact, it confirms that a trend holds well.
With RSI trend lines Forex traders are able to receive a much earlier warning about upcoming trend changes since RSI trend lines witness a breakout few candles earlier than chart trend lines.
RSI trend lines are especially useful on large time frames.
using System; using System.Collections; using System.Collections.Generic; using System.Text; using PTLRuntime.NETScript; using System.Drawing; namespace ind { //--------------------------------------------------- // Project: RSI // Type: Indicator // Author: PFSoft LLC // Company: PFSoft LLC /www.pfsoft.com/ // Copyright: (C) PFSoft LLC Dnepropetrovsk. Ukraine // Created: Nov, 28,2006 //--------------------------------------------------- public class RSI : NETIndicator { public RSI() : base() { ProjectName = "Relative Strength Index"; SetIndicatorLine("line1", Color.Green, 1, LineStyle.SimpleChart); SetIndicatorLine("line2", Color.SkyBlue, 1, LineStyle.SimpleChart); SetLevelLine("line3", UpLine, Color.Red, 1, LineStyle.SimpleChart); SetLevelLine("line4", BottomLine, Color.Yellow, 1, LineStyle.SimpleChart); SeparateWindow = true; } public const int RSI_METHOD_SIMPLE = 0; public const int RSI_METHOD_EXPON = 1; [InputParameter("RSI Period: ", 0, 1, 100, 0, 1)] public int RSIPeriod = 20; [InputParameter("RSI Method: ", 0, new object[] { "Simple", RSI_METHOD_SIMPLE, "Exponential", RSI_METHOD_EXPON} )] public int RSIMethod = RSI_METHOD_EXPON; [InputParameter("Up line level", 2, 0.0, 100.0, 0, 1)] public double UpLine = 80.0; [InputParameter("Bottom line level", 3, 0.0, 100.0, 0, 1)] public double BottomLine = 20.0; [InputParameter("Period of Moving Average", 4)] public int MAPeriod = 5; [InputParameter("Type of Moving Average", 5, new object[] { "Simple", "SMA", "Exponential", "EMA", "Modified", "MMA", "Linear Weighted", "LWMA"} )] public string MaType = "SMA"; public IArray U_Buf; // buffer positive diffs public IArray D_Buf; // buffer negative diffs double pos, neg; public override void Init() { platform.SetIndexBuffer(5, ref U_Buf); platform.SetIndexBuffer(6, ref D_Buf); } public override void OnQuote() { int count = platform.BarsCount(platform.Symbol, platform.Period); if (count < 2) return; double df = ptl.Close[0] - ptl.Close[1]; pos = df > 0 ? df : 0; neg = df < 0 ? -df : 0; if (count <= RSIPeriod) { U_Buf[0] = ((double)U_Buf[1] * (count - 1) + pos) / count; D_Buf[0] = ((double)D_Buf[1] * (count - 1) + neg) / count; return; } switch (RSIMethod) { case RSI_METHOD_SIMPLE: CalcSimple(count); break; case RSI_METHOD_EXPON: CalcExpon(count); break; } platform.SetValue(1, 0, GetMA(count)); } public double GetSMA(int count) { int i = 0; // Usual counter double summa = 0.0; // Sum of prices // Loop of calculation. The loop skips empty bars while ((i < MAPeriod) && (i < count)) { summa += platform.Array[0, i]; i++; } // Returning current value of the SMA return summa / MAPeriod; } public double GetEMA(int count) { // Calculation of a coefficient double k = 2.0 / (MAPeriod + 1); // Getting current price double value1 = platform.Array[0, 1]; // returning value return value1 + k * (ptl.Array[0] - value1); } public double GetMMA(int count) { int i = 0; // Usual counter double mma = ptl.Array[0]; // Current price double k = 1.0 / MAPeriod; // coefficient // Loop of calculation. The loop skips empty bars while ((i < MAPeriod) && (i < count)) { // Bar is not empty, adding it's price to the summa double price = platform.Array[0, i]; mma = price * k + mma * (1.0 - k); // going to the next bar i++; } // Returning of mma return mma; } public double GetLWMA(int count) { int i = 0; // Usual counter double numerator = 0.0; // Numerator of the rate double denominator = 0.0; // Denominator of the rate double k = 1.0 / MAPeriod; // coefficient int period = MAPeriod; // Loop of calculation. The loop skips empty bars while ((i < MAPeriod) && (i < count)) { numerator += period * platform.Array[0, i]; denominator += period; period--; i++; } // returning current value if (denominator > 0.0) return numerator / denominator; else return 0.0; } public double GetMA(int count) { double result = 0.0; switch (MaType) { case "SMA": result = GetSMA(count); break; case "EMA": result = GetEMA(count); break; case "LWMA": result = GetLWMA(count); break; case "MMA": result = GetMMA(count); break; } return result; } public void CalcSimple(int count) { double prepos = 0, preneg = 0; if (count > RSIPeriod + 1) { double pre = ptl.Close[RSIPeriod] - ptl.Close[RSIPeriod + 1]; if (pre >= 0) prepos = pre; else preneg = -pre; } double U, D; U_Buf[0] = U = (double)U_Buf[1] + (pos - prepos) / RSIPeriod; D_Buf[0] = D = (double)D_Buf[1] + (neg - preneg) / RSIPeriod; //double rsi = 100 * (1.0 - 1.0 / (1.0 + U_Buf[0] / D_Buf[0])); double rsi; if (U == 0 && D == 0) rsi = 50; else rsi = 100 * U / (U + D); ptl.Array[0] = rsi; platform.SetValue(0, 0, rsi); } public void CalcExpon(int count) { double rsi; double U, D; U_Buf[0] = U = ((double)U_Buf[1] * (RSIPeriod - 1) + pos) / RSIPeriod; D_Buf[0] = D = ((double)D_Buf[1] * (RSIPeriod - 1) + neg) / RSIPeriod; //rsi = 100 * (1.0 - 1.0 / (1.0 + U_Buf[0] / D_Buf[0])); if (U == 0 && D == 0) rsi = 50; else rsi = 100 * U / (U + D); ptl.Array[0] = rsi; platform.SetValue(0, 0, rsi); } } }
Comments