Created
January 18, 2019 20:58
-
-
Save rgjurgens/55166039aa07b3c709634e2168925d97 to your computer and use it in GitHub Desktop.
Jared algos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rudolf trial and error | |
index = BNCE_XBTUSD; | |
magnTresh = index[0]/500 // start trading from this drop magnitude | |
magnSpeed = magnTresh/100 // minimal consistent change per second | |
function rc(t, x){ | |
x = x.slice(0,t+1); s = 0; | |
for(j=0;j<x.length-1;j++){ | |
s += x[j]-x[j+1]; | |
} | |
return s / x.length; | |
} | |
function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } | |
function dirCount(f, s){ | |
dir = sign(f[0]-s[0]); | |
count = 0; end = f[0]; magn = 0 | |
for(i=0;i<f.length;i++){ | |
if(sign(f[i]-s[i])!=dir){magn = end-f[i]; break;}else{count++;} | |
} | |
return [count, magn]; | |
} | |
function sma(t, xc){ | |
som=0; xc=xc.slice(0,t); | |
for(i=0;i<xc.length;i++){som+=xc[i];} | |
return som/xc.length; | |
} | |
FAST[0] = sma(10, index) | |
SLOW[0] = sma(30, index) | |
FASTRC[0] = rc(30, FAST); | |
FASTRCF[0] = rc(10, FAST); | |
FASTRCFF[0] = rc(3, FAST); | |
RCDIFF[0] = FASTRCF[0]-FASTRC[0]; | |
FASTRCFFRC[0] = rc(3, FASTRCFF); | |
dir = dirCount(FAST, SLOW); | |
DIRTIME[0] = dir[0]; | |
DIRMAGN[0] = dir[1]; | |
if(DIRMAGN[0]<-magnTresh&&DIRMAGN[0]<-DIRTIME[0]*magnSpeed){mark("m")} | |
DROPREBOUND[0] = function(){ | |
if((FAST[0]<SLOW[(DIRTIME[0]*2)]+(DIRMAGN[0]*0.7)) // should really be a long term drop, not a peak | |
&&(DIRMAGN[0]<-magnTresh&&DIRMAGN[0]<-DIRTIME[0]*magnSpeed) | |
&&RCDIFF[0]>0&&FASTRCF[0]>0&&FASTRCFFRC[0]>0&&FAST[0]<SLOW[0]){ return 1} | |
if(RCDIFF[0]<0&&FASTRCFF[0]<0){ return -1} // over the top | |
return 0 | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment