Last active
January 21, 2019 14:30
-
-
Save Schellinkhoutkamp/60f82733849b621303e74d34a57c54bc to your computer and use it in GitHub Desktop.
Jared algos
This file contains 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
// TRADES ON DROP REBOUNDS TOM 20-1 | |
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 dirChange(f, s){ | |
f=f.slice(0,2); | |
if(sign(f[0]-s[0])!=sign(f[f.length-1]-s[f.length-1])){return true} | |
return false | |
} | |
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; | |
} | |
function cci(xc, t){ | |
meandeviation = 0; deviation=0; smanew=0; som=0; xc=xc.slice(0,t); | |
for(i=0;i<xc.length;i++){som+=xc[i];} | |
smanew = som/xc.length; | |
for(i=0;i<xc.length;i++){deviation+=smanew-(Math.sqrt((xc[i])*(xc[i])));} | |
meandeviation = deviation/xc.length; | |
return meandeviation; | |
} | |
XBTCCI[0]=cci(index, 20); log(XBTCCI[0]); | |
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); | |
if(dirChange(FAST, SLOW)||FAST.length<2){ | |
DIRTIME[0]=0; DIRMAGN[0]=0; | |
}else{ | |
DIRTIME[0] = DIRTIME[1]+1; DIRMAGN[0] = DIRMAGN[1]+FAST[0]-FAST[1]; | |
} | |
DROPREBOUND[0] = function(){ | |
if(FAST[0]<SLOW[(DIRTIME[0]*2)]+(DIRTIME[0]*magnSpeed)/2){ // should really be a long term drop, not a peak | |
if(DIRMAGN[0]<-magnTresh&&DIRMAGN[0]<-DIRTIME[0]*magnSpeed){ | |
mark("m") | |
if(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