PowerRSI Indicator
Input:
?Factor( 1 ),
? ? ?RSILength(7), SmoothLength( 50 ), price((o+c)/2),mult(0.0005),
? ? ?DrawHLines(false);
var:
? ?k_15(15),
? ?RSIWAvg(0),
? ?lastRSIAtPivotLo(0),lastPriceAtPivotLo(0),
? ?lastRSIAtPivotHi(0),lastPriceAtPivotHi(0),
idx(0), RSIAvg(0),
? ?longThreshold(0),shrtThreshold(0),
? ?xRSI(0);
If MTF( Factor ) Then
Begin
xRSI = ?_RSI( Factor, Price, RSILength );
RSIAvg ?= AverageMTF( Factor, xRSI, SmoothLength );
longThreshold = 60 - ( 100-RSIAvg ) / 1.68;
shrtThreshold = 40 + ( RSIAvg ) / 1.68;
RSIWAvg ?= WAverageMTF( Factor, xRSI, 3 );
{ drawing related variables }
var: lngDiverColor(green),lngRSIColor(darkgreen),lngRevDiverColor(cyan);
var: srtDiverColor(red), ?srtRSIColor(darkred), ?srtRevDiverColor(yellow);
var: HLLongID(-1), HLShortID(-1), HLLongPrice(0), HLShortPrice(0);
{ long signal }
if RSIWAvg > RSIWAvg[ Factor ] and
? RSIWAvg[ Factor ] < RSIWAvg[ 2 * Factor ] and
? RSIWAvg[ 2 * Factor ] < RSIWAvg[ 3 * Factor ] and
? RSIWAvg[ 3 * Factor ] < RSIWAvg[ 4 * Factor ] then begin { last bar was a RSI pivot low }
? if RSIWAvg[ Factor ] < (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 < xRSI then ? { RSI ? was lower => divergence } begin
? ? ? ? { plot a "significant" long signal }
? ? ? ? Plot1(L-L*mult,"long",lngDiverColor);
? ? ? ? if (DrawHLines) then
? ? ? ? ? ?HLLongID = eKamLine(date,time,Price,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?date,time,Price,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?false,false,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?lngDiverColor,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Tool_dotted);
? end
? else if RSIWAvg[ Factor ] < longThreshold then begin
? ? ? ?{ no divergence, but RSI very low, and so it's worth noting }
? ? ? ? { plot a normal long signal }
? ? ? ? Plot1(PriceMTF( Factor, Low )-PriceMTF( Factor, Low )*mult,"long",lngRSIColor);
? ? ? ? if (DrawHLines) then
? ? ? ? ? ?HLLongID = eKamLine(date,time,PriceMTF( Factor, Price ),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?date,time,PriceMTF( Factor, Price ),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?false,false,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?lngRSIColor,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Tool_dotted);
? end
? else if RSIWAvg[ Factor ] > (shrtThreshold - k_15) { RSI was "high enough" }
? ? ?{ a pivot low while RSI reading is high, look for rev divergence }
? ? ?and PriceMTF( Factor, Price ) > lastPriceAtPivotLo ? ? { price was higher in last RSI pivot low, but }
? ? ?and lastRSIAtPivotLo < xRSI then ? { RSI was lower => rev divergence } begin
? ? ? ? Plot1(PriceMTF( Factor, Low )-PriceMTF( Factor, Low )*mult,"long",lngRevDiverColor);
? ? ? ? if (DrawHLines) then
? ? ? ? ? ?HLLongID = eKamLine(date,time,PriceMTF( Factor, Price ),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?date,time,PriceMTF( Factor, Price ),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?false,false,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?lngRevDiverColor,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Tool_dotted);
? end;
? lastPriceAtPivotLo = PriceMTF( Factor, Price );
? lastRSIAtPivotLo ? = xRSI;
end;
if HLLongID <> -1 then
? TL_SetEnd( HLLongID, Date, Time, lastPriceAtPivotLo ) ;
{ short signal }
if RSIWAvg[ Factor ] > RSIWAvg and
? RSIWAvg[ Factor ] > RSIWAvg[ 2 * Factor ] and
? RSIWAvg[ 2 * Factor ] > RSIWAvg[ 3 * Factor ] and
? RSIWAvg[ 3 * Factor ] > RSIWAvg[ 4 * Factor ] then begin { last bar was a RSI pivot high }
? if RSIWAvg[ Factor ] > (shrtThreshold - k_15) and { RSI was "high enough" }
? ? ?{ RSI high enough for a pivot high, look for divergence }
? ? ?PriceMTF( Factor, Price ) > lastPriceAtPivotHi and { price was higher in last RSI pivot high, but }
? ? ?lastRSIAtPivotHi > xRSI then ? { RSI ? was higher => divergence } begin
? ? ? ? { plot a "significant" short signal }
? ? ?Plot2(PriceMTF( Factor, High )+PriceMTF( Factor, High )*mult,"short",srtDiverColor);
? end
? else begin
? ? ?if RSIWAvg[ Factor ] > shrtThreshold then begin
? ? ? ?{ no divergence, but RSI very high, and so it's worth noting }
? ? ? ? { plot a normal short signal }
? ? ?Plot2(PriceMTF( Factor, High )+PriceMTF( Factor, High )*mult,"short",srtRSIColor);
? ? ?end;
? end;
? if RSIWAvg[ Factor ] < (longThreshold + k_15) and { RSI was "low enough" }
? ? ?{ a pivot high while RSI reading is low, look for rev divergence }
? ? ?PriceMTF( Factor, Price ) < lastPriceAtPivotHi and { price was lower in last RSI pivot high, but }
? ? ?lastRSIAtPivotHi > xRSI then ? { RSI ? was higher => rev divergence } begin
? ? ?Plot2(PriceMTF( Factor, High )+PriceMTF( Factor, High )*mult,"short",srtRevDiverColor);
? end;
? lastPriceAtPivotHi = PriceMTF( Factor, Price );
? lastRSIAtPivotHi ? = xRSI;
end;
End;