RWI System

#1
I need help to plot Ribbon for this system according to its buy-sell signals.

Hope seniors might be able to help.


Code of RWI System


Code:
_SECTION_BEGIN("Background");
	SetChartBkColor(ParamColor("Outer panel",colorBlack)); // color of outer border 
	SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
	tchoice=Param("Title Selection ",2,1,2,1);
_SECTION_END();

_SECTION_BEGIN("RWI");
minperiods = Param( "Min Periods", 9, 1, 200, 1 );
maxperiods = Param( "Max Periods", 40, 1, 200, 1 );
Uptrend = RWI(9,40) > RWILo(9,40) OR RWI(9,40) > MA(RWI(9,40),5);
downtrend = RWI(9,40) < RWILo(9,40)OR RWI(9,40) < MA(RWI(9,40),5);
Plot( RWI( minperiods, maxperiods)  , _DEFAULT_NAME(),IIf( uptrend, colorBrightGreen, IIf( downtrend, colorRed, 0 )), ParamStyle("Style") );
Plot(0,"",colorYellow,styleLine);

_SECTION_END();

_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA( P, 5 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 

_SECTION_END();

_SECTION_BEGIN("RWILO");
minperiods = Param( "Min Periods", 9, 1, 200, 1 );
maxperiods = Param( "Max Periods", 40, 1, 200, 1 );
Uptrend = RWI(9,40) > RWILo(9,40) OR RWILo(9,40) < MA(RWI(9,40),5);
downtrend = RWI(9,40) < RWILo(9,40) OR RWILo(9,40) > MA(RWI(9,40),5); 
Plot( RWILo( minperiods, maxperiods)  , _DEFAULT_NAME(), IIf( uptrend, colorGold, IIf( downtrend, colorRed, 0 )), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("SIGNAL");

minperiods = Param( "Min Periods", 9, 1, 200, 1 );
maxperiods = Param( "Max Periods", 40, 1, 200, 1 );

Buy	=	RWI(minperiods, maxperiods) > RWILo(minperiods, maxperiods) AND RWI( minperiods, maxperiods) > 0;
Sell	=	RWI(minperiods, maxperiods) < RWILo(minperiods, maxperiods) AND RWI( minperiods, maxperiods) < 0;
Buy	=	ExRem(Buy,Sell);
Sell	=	ExRem(Sell,Buy);

PlotShapes(shapeUpArrow * Buy,  colorBlue,  0, RWILo( minperiods, maxperiods));
PlotShapes(shapeDownArrow * Sell, colorRed, 0,   RWI( minperiods, maxperiods));
_SECTION_END();



Thanx you in advance.

Waiting
 
#4
hi

just add these lines and get ribbon

HTML:
Buy=Uptrend;
Sell = downtrend;
Plot( 1, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
What is RWI and how to apply it?
If you want to use RWI,you must know how it is created and how it can be applied to get buy or sell signals.

The Random Walk Index (RWI) is used to determine if an issue is trending or in a random trading range by comparing it to a straight line. The more random the price movement, the more the RWI fluctuates.

The short-term (2 to 7 periods) RWI is an overbought/oversold indicator,
while the long-term (8 to 64 periods) RWI is a trend indicator.

An issue is trending higher if the RWI of the highs is greater than 1, while a downtrend is indicated if the RWI of the lows is greater than 1.

A Buy signal is generated 1)when the long-term RWI of the highs is greater than 1 and 2)the short-term RWI of the lows rises above 1.
A Sell signal is generated 1)when the long-term RWI of the lows is greater than 1 and 2)the short-term RWI of the highs rises above 1.

The Random Walk Index was developed by Michael Poulos and is described in his article in the February, 1991 issue of Technical Analysis of Stocks & Commodities magazine.

rwi(9,40)
Calculates the Random Walk Index indicator as a difference between Random Walk Index from Highs (RWIHI() function) and Random Walk Index from Lows (RWILO() function.
EXAMPLE rwi( 9, 40 );
before using a complex code,
Use this code below on a chart and get a clear idea(it resembles adx,pdi,mdi)
-----------------------------------------------------
Plot(RWIHi( 9, 40 )," rwihi",colorGreen,styleThick);
Plot(RWILo( 9, 40 )," rwilo",colorRed,styleThick);
Plot(RWI( 9, 40 )," rwi",colorBlue,styleThick);
Plot(1,"1",colorBlack,styleLine);

-------------------------------------------------------
 
Last edited:
#6
Hi

Do you want to use RWI random walk index?
Then you need to be aware of following things
ref
//http://www2.wealth-lab.com/WL5Wiki/RWIHigh.ashx
Short Term RWI uses (minperiod = 2 and maxperiod = 7 )SAY
RWISHORTTERM = RWI(2,7)
Long Term RWI uses (minperiod = 8 and maxperiod = 64 )SAY
RWILONGTERM = RWI(8,64)

Trends
==============
Long Term RWI of Lows above 1 indicates a sustainable down trend =RWILo(8,64)>1
Long Term RWI of Highs above 1 indicates a sustainable uptrend =RWIHi(8,64)>1

Peaks & Troughs
===============
Short Term RWI of Lows peaking above 1 indicates a price peak
= RWILo(2,7)>1
Short Term RWI of Highs peaking above 1 indicates a price trough =RWIHi(2,7)>1

----------------------------------------------------------------------
A) Enter long or cover when Long Term RWI of Highs is above 1 and B)Short Term RWI of Lows peaks above 1(PRICE PEAK OCCURS- sometimes this may not happen)
Condition A is vital for uptrend- condition B is secondary.
--------------------------------------------------------------
C) Enter short or sell when Long Term RWI of Lows is above 1 and
D)Short Term RWI of Highs peaks above 1 (price trough occurs-sometimes this may not happen)
Condition C is vital for downtrend-condition D is secondary

In the afl provided, they used (9,40) -means a long term rwi is used.
 
Last edited:

Similar threads