Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Rudolf, the first thing I would do here is try to get to understand your RSI/price divergence formula.
Giving variables meaningful names, and enabling the If(cbull=1,1,1) Bull condition, can result in something like this indicator:
[code:1:14cef3a922]
{ User inputs }
HiLoPds:=Input("HHV/LLV periods",3,260,15);
minPds:=Input("Minimum Bull/Bear periods",0,260,0);
bullSwitch:=Input("Bull condition filter: [1]On, [0]Off",0,1,0);
bearSwitch:=Input("Bear condition filter: [1]On, [0]Off",0,1,0);
{ Data array }
data:=C;
{ Indicator }
indic:=RSI(data,14);
{ Enable/disable Bull/Bear switches }
condBull:=If(bullSwitch,indic<35,1);
condBear:=If(bearSwitch,indic>65,1);
{ Lowest data/indicator values }
loData:=LLV(data,HiLoPds);
loDataBars:=LLVBars(data,HiLoPds);
loIndic:=LLV(indic,HiLoPds);
loIndicBars:=LLVBars(indic,HiLoPds);
loIndicVal:=ValueWhen(1,data=loData,indic);
{ Highest data/indicator values }
hiData:=HHV(data,HiLoPds);
hiDataBars:=HHVBars(data,HiLoPds);
hiIndic:=HHV(indic,HiLoPds);
hiIndicBars:=HHVBars(indic,HiLoPds);
hiIndicVal:=ValueWhen(1,data=hiData,indic);
{ Bull condition }
bull:=condBull
AND loData=data
AND loIndicVal>loIndic
AND Abs(loDataBars-loIndicBars)>=minPds;
{ Bear condition }
bear:=condBear
AND hiData=data
AND hiIndicVal<hiIndic
AND Abs(hiDataBars-hiIndicBars)>=minPds;
{ Plot signals in own window }
bull-bear
[/code:1:14cef3a922]
The next step would be to replace your price data array within the formula, with the Relative Strength Comparative of price/NYSE index:
[code:1:14cef3a922]
{ User inputs }
HiLoPds:=Input("HHV/LLV periods",3,260,15);
minPds:=Input("Minimum Bull/Bear periods",0,260,0);
bullSwitch:=Input("Bull condition filter: [1]On, [0]Off",0,1,0);
bearSwitch:=Input("Bear condition filter: [1]On, [0]Off",0,1,0);
{ Data array }
data:=Fml("URSC-US Chart vs NYSE");
{ Indicator }
indic:=RSI(data,14);
{ Enable/disable Bull/Bear switches }
condBull:=If(bullSwitch,indic<35,1);
condBear:=If(bearSwitch,indic>65,1);
{ Lowest data/indicator values }
loData:=LLV(data,HiLoPds);
loDataBars:=LLVBars(data,HiLoPds);
loIndic:=LLV(indic,HiLoPds);
loIndicBars:=LLVBars(indic,HiLoPds);
loIndicVal:=ValueWhen(1,data=loData,indic);
{ Highest data/indicator values }
hiData:=HHV(data,HiLoPds);
hiDataBars:=HHVBars(data,HiLoPds);
hiIndic:=HHV(indic,HiLoPds);
hiIndicBars:=HHVBars(indic,HiLoPds);
hiIndicVal:=ValueWhen(1,data=hiData,indic);
{ Bull condition }
bull:=condBull
AND loData=data
AND loIndicVal>loIndic
AND Abs(loDataBars-loIndicBars)>=minPds;
{ Bear condition }
bear:=condBear
AND hiData=data
AND hiIndicVal<hiIndic
AND Abs(hiDataBars-hiIndicBars)>=minPds;
{ Plot signals in own window }
bull-bear
[/code:1:14cef3a922]
Unfortunately you will need the URSC tool-kit for the above indicator to work. RSC is a complex process to program correctly in MetaStock.
jose '-)
|