| |
 |
Views:
2452 |
| Added: July 19, 2008 |
| |
| |
|
| This formula has not been rated yet |
|
|
| |
email this link
|
| |
| |
| Tags:
TradeStation, indicator
|
| |
 |
Code:
Type : Indicator, Name : Power RSI Pivot
{***********************************************************************
Indicator..........: Power RSI Pivot by FEDSignal.com
Destination........: Counter-Trend System
E-Mail.............: info[at]fedsignal.com
Last Modified Date.: 06/26/2003
Type Signals.......: Only RSI Pivot
Interval Settings..: Tick Bar, Volume Bar, TimeBar.
Aplication.........: RadarScreen 7.XX, TradeStation 7.XX
*************************************************************************}
{
Orc, 6/27/2003 - posted on
https://www.tradestationworld.com/discussions/topic.asp?TOPIC_ID=13560
https://www.tradestationworld.com/discussions/topic.asp?TOPIC_ID=13560
eKam, 6/29/2003 - code cleaned up
- added short signals
ekam, 7/26/2003 - plot support / resistence lines
- added reverse divergence signals
ekam, 7/30/2003 - added alerts in the style of combs and RalphP
richkin,
1/10/2004 - changed colors to input variables to allow more plotting flexibility
- changed input variable names to improve readability
}
Input:
Length(7),price((o+c)/2),mult(0.0005),
DrawHLines(true);
{ drawing related variable inputs }
Input: longDiverColor(green), longRSIColor(darkgreen), longRevDiverColor(cyan);
Input: shortDiverColor(red), shortRSIColor(darkred), shortRevDiverColor(yellow);
var:
k_15(15), k_50(50),
RSIWAvg(0),
lastRSIAtPivotLo(0),lastPriceAtPivotLo(0),lastLoAtPivotLo(0),
lastRSIAtPivotHi(0),lastPriceAtPivotHi(0),lastHiAtPivotHi(0);
{ figure out long/short threshold }
var:
idx(0), RSIAvg(0),
longThreshold(0),shrtThreshold(0),
_RSI(0);
var:
alertTextID(-1);
if barnumber = 1 then begin
alertTextID = Text_New(date,time,0,"RSI");
end;
_RSI = RSI(Price,Length);
RSIAvg = Average(_RSI,k_50);
longThreshold = 60 - (100-RSIAvg)/1.68;
shrtThreshold = 40 + (RSIAvg)/1.68;
RSIWAvg = WAverage(RSI(Price,Length),3);
{ long signal }
if RSIWAvg[1] < RSIWAvg and
RSIWAvg[1] < RSIWAvg[2] and
RSIWAvg[2] < RSIWAvg[3] and
RSIWAvg[3] < RSIWAvg[4] then begin { last bar was a RSI pivot low }
if RSIWAvg[1] < (longThreshold + k_15) and { RSI was "low enough" }
{ RSI low enough for a pivot low, look for divergence }
Price < lastPriceAtPivotLo and { price was higher in last RSI pivot low, but }
lastRSIAtPivotLo < _RSI then { RSI was lower => divergence } begin
{ plot a "significant" long signal }
Plot1(L-L*mult,"long",longDiverColor);
if Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI diver long");
end;
end
else if RSIWAvg[1] < longThreshold then begin
{ no divergence, but RSI very low, and so it's worth noting }
{ plot a normal long signal }
Plot1(L-L*mult,"long",longRSIColor);
if Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI long");
end;
end
else if RSIWAvg[1] > (shrtThreshold - k_15) { RSI was "high enough" }
{ a pivot low while RSI reading is high, look for rev divergence }
and Price > lastPriceAtPivotLo { price was higher in last RSI pivot low, but }
and lastRSIAtPivotLo < _RSI then { RSI was lower => rev divergence } begin
Plot1(L-L*mult,"long",longRevDiverColor);
if Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI rev diver long");
end;
end;
lastPriceAtPivotLo = Price;
lastLoAtPivotLo = L;
lastRSIAtPivotLo = _RSI;
end;
if DrawHLines and lastLoAtPivotLo <> 0 then begin
plot3(lastLoAtPivotLo,"lastL@pivotL");
if lastLoAtPivotLo <> lastLoAtPivotLo[1]
and Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI support");
end;
end;
if DrawHLines and lastHiAtPivotHi <> 0 then begin
plot4(lastHiAtPivotHi,"lastH@pivotH");
if lastHiAtPivotHi <> lastHiAtPivotHi[1]
and Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI resistance");
end;
end;
{ short signal }
if RSIWAvg[1] > RSIWAvg and
RSIWAvg[1] > RSIWAvg[2] and
RSIWAvg[2] > RSIWAvg[3] and
RSIWAvg[3] > RSIWAvg[4] then begin { last bar was a RSI pivot high }
if RSIWAvg[1] > (shrtThreshold - k_15) and { RSI was "high enough" }
{ RSI high enough for a pivot high, look for divergence }
Price > lastPriceAtPivotHi and { price was higher in last RSI pivot high, but }
lastRSIAtPivotHi > _RSI then { RSI was higher => divergence } begin
{ plot a "significant" short signal }
Plot2(H+H*mult,"short",shortDiverColor);
if Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI diver short");
end;
end
else begin
if RSIWAvg[1] > shrtThreshold then begin
{ no divergence, but RSI very high, and so it's worth noting }
{ plot a normal short signal }
Plot2(H+H*mult,"short",shortRSIColor);
if Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI short");
end;
end;
end;
if RSIWAvg[1] < (longThreshold + k_15) and { RSI was "low enough" }
{ a pivot high while RSI reading is low, look for rev divergence }
Price < lastPriceAtPivotHi and { price was lower in last RSI pivot high, but }
lastRSIAtPivotHi > _RSI then { RSI was higher => rev divergence } begin
Plot2(H+H*mult,"short",shortRevDiverColor);
if Text_GetTime(alertTextID) <> time then begin
text_setLocation(alertTextID, date, time, 0);
alert("RSI rev diver short");
end;
end;
lastPriceAtPivotHi = Price;
lastHiAtPivotHi = H;
lastRSIAtPivotHi = _RSI;
end;
{
the original code follows:
}
{
Input:Length(7);
Vars: Condition99(FALSE),
Value8(15),
Value3(50);
Value1 = WAverage(RSI(Close,Length),3);
Value2 = 0;
For Value7 = 0 to Value3
Begin
Value2 = Value2 + RSI(Close,Length)[Value7];
End;
Value4 = Value2/(Value3-1);
Value5 = 100 - (100-Value4)/1.68;
Value6 = Value5 - 40;
If Value1[1] < Value1 and Value1[1] < Value1[2] and Value1[2] < Value1[3]
and Value1[3] < Value1[4] then
Begin
If Value1[1] < (Value6 + Value8) and Value9 > (Open + Close)/2 and Value10 < RSI(Close,Length) then
Begin
Plot1(L-C*0.001,"Pivot-sB");
Condition99 = FALSE;
Value9 = (Open + Close)/2;
Value10 = RSI(Close,Length);
End
Else
Begin
If Value1[1] < Value6 then
Begin
Plot2(L-C*0.001,"Pivot-B");
Condition99 = TRUE;
Value9 = (Open + Close)/2;
Value10 = RSI(Close,Length);
End;
End;
End;
}
Source: https://www.tradestation.com
all formulas for TradeStation
all formulas
|