Indicators -

Posted By: Bennycjones

Indicators - - 04/01/21 01:25

Hey guys -

Really loving Zorro so far.

Still a bit of a noob to coding, but thought I'd contribute where I can. Been transposing some indicators from tradingview. Any new ones I'll post here for your pleasure...

I cannot promise they are all perfect, but I will check them before I post them. However, on the brightside, most of them probably couldn't be too much worse...

anyways.. first one for you. QQE. Feel free to make the code much better. This is basically just two RSI's for all the hype it gets.

//default smoothing factor 5. Default len = 14.
var QQEF(var * src, var len, var smooth)
{

vars RSI = series(RSI(src, len));
vars RSII = series(EMA(RSI, smooth));

return RSII[0];
}
var QQES(var * src, var len, var smooth)
{

vars RSI = series(RSI(src, len));
vars RSII = series(EMA(RSI, smooth));
var tr = abs(RSII[0] - RSII[1]);
var wwalpha = (1/len);
var wwMI = wwalpha * tr + (1 - wwalpha);
vars WwMII = series(wwMI);
var WWMI = WwMII[0] * WwMII[1];
var atrrsi = wwalpha*WWMI + (1-wwalpha);
vars Atrrsi = series(atrrsi);
var ATRRSI = Atrrsi[0] * Atrrsi[1];

var QUP = RSII[0] + ATRRSI * 4.236;
var QDN = RSII[0] - ATRRSI * 4.236;

vars QQES = series(0.00);


QQES[0] = QQES[1];

if (QUP < QQES[1])
QQES[0] = QUP;
if (RSII[0] > QQES[1] && RSII[1] < QQES[1])
QQES[0] = QDN;
if (QDN > QQES[1])
QQES[0] = QDN;
if (RSII[0] < QQES[1] && RSII[1] > QQES[1])
QQES[0] = QUP;



return QQES[0];
}
Posted By: Bennycjones

Re: Indicators - - 04/04/21 00:31

Ehlers swiss army knife.





var Ehlers_swiss_army_knife(int type, vars src, var len)
{
//Variables....
var pi = 2 * asin(1);
var c0 = 1;
var c1 = 0;
var b0 = 1;
var b1 = 0;
var b2 = 0;
var a1 = 0;
var a2 = 0;
var alpha = 0;
var beta = 0;
var gamma = 0;
var cycle = 2 * pi / len;






switch(type){

//ehlers EMA
case 1:
alpha = (cos(cycle) + sin(cycle) - 1) / cos(cycle);
b0 = alpha;
a1 = 1 - alpha;
//Gaussian
case 2:
beta = 2.415 * (1 - cos(cycle));
alpha = -beta + sqrt((beta * beta) + (2 * beta));
c0 = alpha * alpha;
a1 = 2 * (1 - alpha);
a2 = -(1 - alpha) * (1 - alpha);
//butterworth
case 3:
beta = 2.415 * (1 - cos(cycle));
alpha = -beta + sqrt((beta * beta) + (2 * beta));
c0 = alpha * alpha / 4;
b1 = 2;
b2 = 1;
a1 = 2 * (1 - alpha);
a2 = -(1 - alpha) * (1 - alpha);
//Bandstop...
case 4:
beta = cos(cycle);
gamma = 1 / cos(cycle*2*0.1); // delta default to 0.1. Acceptable delta -- 0.05<d<0.5
alpha = gamma - sqrt((gamma * gamma) - 1);
c0 = (1 + alpha) / 2;
b1 = -2 * beta;
b2 = 1;
a1 = beta * (1 + alpha);
a2 = -alpha;
//plain old sma
case 5:
c1 = 1 / len;
b0 = 1 / len;
a1 = 1;
//exponential
case 6:
alpha = 2/(len+1);
b0 = alpha;
a1 = 1 - alpha;
case 7:
alpha = 1 / len;
b0 = alpha;
a1 = 1 - alpha;
}
vars output = series(src[0]);

output[0] = (c0 * ((b0 * src[0]) + (b1 * src[1]) + (b2 * src[2]))) + (a1 * output[1]) + (a2 * output[2]) - (c1 * src[len]);




return output[0];

}
© 2024 lite-C Forums