Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, AndrewAMD, Imhotep, TipmyPip, Edgar_Herrera), 809 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Ehler's Adaptive RSI #459613
05/27/16 20:09
05/27/16 20:09
Joined: Mar 2016
Posts: 4
Y
yoki Offline OP
Guest
yoki  Offline OP
Guest
Y

Joined: Mar 2016
Posts: 4
Hello everyone,
I'm relatively new to the forum and zorro. I just wanted to be sure that Ehler's adaptive RSI indicator from his "Cycle Analytics for Traders" book is not on the zorro indicator list. is that right? just want to be sure before I attempt to code it lol.

Re: Ehler's Adaptive RSI [Re: yoki] #459729
06/02/16 05:53
06/02/16 05:53
Joined: Mar 2016
Posts: 4
Y
yoki Offline OP
Guest
yoki  Offline OP
Guest
Y

Joined: Mar 2016
Posts: 4
I've worked a little bit on converting John Ehler's Easy Language code for his adaptive RSI into zorro code. I'm a beginner to coding in general and have only gone through a beginner's python course. Hoping that somebody can help me put this together.

Below is John Ehler's Easy Language code for the adaptive RSI:

Quote:

//Declares all variables...

//Highpass filter cyclic components whos periods are shorter than 48 bars
Alpha1 = (Cosine(.707*360/48) + Sine (.707*360 / 48) – 1) / Cosine (.707*360 / 48);
HP = (1-alpha1 / 2) * (1 – alpha1 / 2) * (Close – 2*Close[1]) + Close[2]) + 2*(1-alpha1*HP[1] – (1-alpha1)*(1-alpha1)*HP[2]
//Smooth with a super smoother filter
a1 = exp(-1.414*3.14159 / 10);
b1 = 2*a1*cos(1.414*180 / 10);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;
Filt = c1*(HP + HP[1]) / 2 + c2*Filt[1] + c3 * Filt[2];

//John Ehlers then proceeds to calculate the dominant cycle with his method (not shown)

//Adaptive RSI
ClosesUp(0);
ClosesDn(0);
Denom(0);
MyRSI(0);
ClosesUp = 0;
ClosesDn = 0;

For Count = 0 to IntPortion(DominantCycle / 2 – 1) Begin
If (Filt[count] > Filt[count + 1])
Then ClosesUp = ClosesUp + (Filt[count] - Filt[count + 1]);

If (Filt[count] < Filt[count + 1])
Then ClosesDn = ClosesDn + (Filt[count + 1] - Filt[count]);

if (Denom[0] <> 0 && Denom[1] <> 0) Then
MyRSI = c1 * (ClosesUp[0] / Denom[0] + ClosesUp[1] / Denom[1]) / 2 + c2 * MyRSI[1] + c3 * MyRSI[2];

Plot1(MyRSI);


Below is my failed attempt at converting the script to zorro's language:

Quote:
//John Ehlers Adaptive RSI from "Cycle Analytics For Traders"

function run(){
var a1 = exp(-1.414*3.14159 / 10);
var b1 = 2*a1*cos(1.414*180 / 10);
var c2 = b1;
var c3 = -a1*a1;
var c1 = 1 - c2 - c3;

vars Price = series(price());
vars PriceSmooth = series(Smooth(Price, 10));

//Highpass Filter
vars HP = series(HighPass1(Price, 48));

//Smooth with SuperSmoother
vars Filt = series(Smooth(HP,10));

//Dominant Period
var Dominant = DominantPeriod(Price, 10);

//Adaptive RSI
var ClosesUp = 0;
var ClosesDn = 0;
int count = 0;

for(count = 0; count < (Dominant / 2); count++) {

if (Filt[count] > Filt[count + 1])
return ClosesUp = ClosesUp + (Filt[count] - Filt[count + 1]);

else if (Filt[count] < Filt[count + 1])
return ClosesDn = ClosesDn + (Filt[count + 1] - Filt[count]);
}

vars MyRSI;
vars Denom = ClosesUp + ClosesDn;

if (Denom[0] != 0 && Denom[1] != 0)
MyRSI = c1 * (ClosesUp[0] / Denom[0] + ClosesUp[1] / Denom[1]) / 2 + c2 * MyRSI[1] + c3 * MyRSI[2];


plot("MyRSI", Dominant, NEW, RED);
}


What I'm mainly not sure about is how to convert the easy language code to zorro that has the same variable one is defining in its equation. f.i. MyRSI = c1 * MyRSI[1] + MyRSI[2]. So I'm really not sure if my "Filt" variable is right and just really now sure how to define the "MyRSI" varaible in zorro. Honestly not sure if any of this is right. Any help would be super appreciated.

Re: Ehler's Adaptive RSI [Re: yoki] #459738
06/02/16 10:52
06/02/16 10:52
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
As far as I can see at a glance, it looks mostly correct except for a few things. The "return" statements in the count loop are not in Ehler's code, and should also not be in the C code. And ClosesUp, Denom, MyRSI must be series, not single variables.

Re: Ehler's Adaptive RSI [Re: jcl] #459779
06/04/16 01:34
06/04/16 01:34
Joined: Mar 2016
Posts: 4
Y
yoki Offline OP
Guest
yoki  Offline OP
Guest
Y

Joined: Mar 2016
Posts: 4
Thanks a lot JCL. I think I got it to right now...maybe. I'll post the script I have here so anyone who wants to implement it into their strategy can. Going to focus on using this for stocks as I've heard that stocks are more mean reverting than forex. Feel free to post if anyone has any ideas on how to make a good strategy using this indicator/oscillator. I'll post here if I find anything interesting.

Quote:
function run(){

var a1 = exp(-1.414*3.14159 / 10);
var b1 = 2*a1*cos(1.414*180 / 10);
var c2 = b1;
var c3 = -a1*a1;
var c1 = 1 - c2 - c3;

vars Price = series(price());
vars PriceSmooth = series(Smooth(Price, 10));
vars SMA200 = series(SMA(Price,200));

//Highpass Filter
vars HP = series(HighPass1(Price, 48));

//Smooth with SuperSmoother
vars Filt = series(Smooth(HP,10));

//Dominant Period
vars Dominant = series(DominantPeriod(Price, 50));


//Adaptive RSI
vars ClosesUp = series(0);
vars ClosesDn = series(0);
vars MyRSI = series(0);
vars Denom = series(0);
int count = 0;

for(count = 0; count < (Dominant[0] / 2 - 1); count++) {

if (Filt[count] > Filt[count + 1])
ClosesUp[0] = ClosesUp[0] + (Filt[count] - Filt[count + 1]);

if (Filt[count] < Filt[count + 1])
ClosesDn[0] = ClosesDn[0] + (Filt[count + 1] - Filt[count]);
}

Denom[0] = ClosesUp[0] + ClosesDn[0];

if (Denom[0] != 0 && Denom[1] != 0)
MyRSI[0] = c1 * (ClosesUp[0] / Denom[0] + ClosesUp[1] / Denom[1]) / 2 + c2 * MyRSI[1] + c3 * MyRSI[2];

plot("MyRSI", MyRSI, NEW, RED);

}


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1