[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Indicator2 applied to indicator1



PureBytes Links

Trading Reference Links

   INDICATOR2 APPLIED TO INDICATOR1

Applying indicator2 to indicator1 means using the data stream from
indicator1 as a feed into indicator2. E.g., using the output of ADX as
an input to RSI or vise versa. Described below is the process of how to
see this done on a chart in TS.

The following discussion involves functions and indicators. Most (if not
all) indicators can be made into a function and vice versa. Functions
are just convenient packages and are not really needed, in that the full
function code can be incorporated into an indicator. This eliminates the
need for calling that function. If you like, that can be done with any
of functions below. In fact, it is often easier to debug not using
functions. The following works in TS4 or TS2000 and I suppose in SC if
the setups are made into an ela file.

1.  If indicator1 does not have a function make one for it and save it
in the function category. You need to add function1 of indicator1 into
the Price point in indicator2. That is, the point where indicator2 is
receiving the data it will process, e.g., indicator2(function1).  In
actuality, indicator2 is often just a call in a plot statement for
function2, e.g., plot1(RSI(Fastk(14),18),"RSIFastk"). This would be
indicator2 which calls two functions, RSI and FastK. We need to pay
attention to whether these are series or simple. If indicator2 is
calling function2 and it is simple then function1 should be assigned to
a variable (say,value1) in indicator2. That variable replaces the Price
in indicator2. If function2 is series (as RSI above is) then function1
needs to be embedded in function2 (as Fastk above is) or as an input in
indicator2. Due to RSI being series, we can have: input: X(Faskt(14));
and plot1(RSI(X,18)," RSIFastk") or the above. It seems that
series2(series1) or series2(simple1) work better than simple2(simple1)
so do not change series functions to simple ones. You will have to
experiment to get the best setup. Inputs for function1 can be hard coded
or included in indicator2. Make sure any unique function1 inputs are
distinct from those for indicator2.

2.  Plot indicator1, with scaling set to "Same as price data", into
subgraph 1 (same as the price data). The inputs must be the same values
as for function1. Do not "hid" the price data (Format Price
Data-Properties-Subgraph-hidden). If indicator1 does not appear or does
not fit the window properly try multiplying function1 with a factor that
scales it to the window. For small valued indicators, such as
AvgTrueRange, a factor of 10 or 20 or 30 may be necessary. The plot of
indicator1 must be multiplied by the same factor. Or try the "User
defined" button under Format Price Data to adjust the scale. The price
data may or may not be visible after this adjustment (if necessary). If
it is not and you want to see it then open another window and plot the
same price data to see what it looks like. The data left/right buttons
can be used to move through charts but if the "User defined" button is
used to adjust the scale it will have to be reset for each chart if you
want to see the graph.

3.  The easiest way to handle scaling is to include a plot of function1
inside indicator2 (see below for TL). Otherwise, you may, in some cases,
only see indicator2 and not indicator1. This would be like seeing a
moving ave but not the price data on which it is based.

4.  Plot indicator2 into subgraph 1 with scaling set to "Same as price
data". You should now have indicator2 applied to indicator1. If you want
to stop the symbol (price) graph from showing use: Format Price
Data-Style-Bar type-Invisible bars.

5.  You can apply indicators to the indicators you have created
yourself. Just make a function from your indicator.

6.  Alerts must be set with the values of indicator2 and indicator1, not
close, high, open, or low. Ever if the plots for indicators 1 and 2 are
compressed to below 1 in the graph window, the alert can be accurately
calculated as there are many digits after the decimal (I hope).

One of the simplest examples is Plot1(RSI(ADX(18),14),"RSI(ADX)"). The
key is setting the scaling and using subgraph 1 (with a plot of ADX if
desired).

//////////////////////////////////

A little more complex is applying a modified Omega Research automatic
trendlines (indicator2) to RSI (indicator1 or function1). The alert will
be caused by the last point of indicator1 crossing under the trendline.
The jpg graph included below shows a normal, lined RSI in subgraph 2 for
comparison. Notice that the values of RSI are the same in the upper and
lower plots. If a function is used here that is of small value, such as
AvgTrueRange, then multiply the function by a factor to make it larger.
......................................................

Z=(factor)*RSI(C,14); {if factor is not be needed set =1}
plot1(Z,"RSI");
 { add Z in SwingHighBar and SwingLowBar }
If SwingHighBar(1, Z, RHStren, RHStren+1)=RHStren then begin
   for Value1=9 downto 0 begin
     RHDate[Value1+1]=RHDate[Value1];
     RHTime[Value1+1]=RHTime[Value1];
     RHVal[Value1+1]=RHVal[Value1];
   end;
   RHDate[0]=Date[RHStren];
   RHTime[0]=Time[RHStren];
   RHVal[0]=Z[RHStren];  {< --- add Z here}
End;
.....................................................................etc

If SwingLowBar(1, Z, RLStren, RLStren+1)=RLStren then begin
   for Value1=9 downto 0 begin
     RLDate[Value1+1]=RLDate[Value1];
     RLTime[Value1+1]=RLTime[Value1];
     RLVal[Value1+1]=RLVal[Value1];
   end;
   RLDate[0]=Date[RLStren];
   RLTime[0]=Time[RLStren];
   RLVal[0]=Z[RLStren];  {<----   add Z here}
End;
................................................etc

{Delete the code for the two alerts (TL_SetAlert(RLTL_Ref,x) {where x=1
or 2 or 3}) and change to something such as:}

If CheckAlert  then
if Z crosses under TL_GetValue(RLTLRef, date, time) then alert=true;
{replace all Close with Z}

///////////////////////////////////////////////////////

Another example is linear regression applied to RSI or ADX or DMI.

Add RSI (or ADX or DMI) into the function "LinearRegLine" as follows:

.............................................

Inputs: Length(Numeric), BarsPlus(Numeric), SlctDate(Numeric),
SlctTime(Numeric), Color(Numeric), ExtRight(TrueFalse);
Variables: LRV(0), LRVAgo(0), TLLRV(0), Flag(0),  Z(0);

Z=RSI(c,14);      {< ------  add here}
{There are two LinearRegValue in TS 4, series and simple. Since this
code works, the simple must be the one used. If the code did not work it
means the series one is called and in that case place RSI inside}
LRV =LinearRegValue( Z, Length, BarsPlus);   {< ------  add here}
LRVAgo =LinearRegValue( Z, Length, Length-1); {< ------  add here}

If LastBarOnChart AND SlctDate = 0 AND Flag = 0 Then Begin
 TLLRV = TL_New(Date[Length-1], Time[Length-1], LRVAgo, Date, Time,
LRV);

......................etc

Now plot RSI in subgraph 1 as outlined above and then the indicator "Lin
Regression Line". I have not worked out an alerts for this case or any
others expect the TL example above. Maybe someone can and post the
results. See the attached jpg file for a shot of this example.

P. S. To have a real linear regression line in TS 4.0, copy the code for
the indicator "Lin Regression Line" and function "LinearRegLine" from
TS2000 into TS 4.0. Apply it as outline here and you have a linear
regression line in TS 4.0 on your indicator of choice.

I thought this subject should reach as wide a group as possible so I am
double posting, something I do not usually do.

Wayne Mathews