Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TRADES ON DROP REBOUNDS
- index = BNCE_XBTUSD;
- tradeAmount = 0.003; // amount to trade
- magnSpeed = 0.00002; // 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];
- minMagn = DIRTIME[0]*magnSpeed*index[0];
- //if(DIRMAGN[0]<-7&&DIRMAGN[0]<-minMagn){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]<-7&&DIRMAGN[0]<-minMagn)
- &&RCDIFF[0]>0.1&&FASTRCF[0]>0&&FASTRCFFRC[0]>0&&FAST[0]<SLOW[0]){ return tradeAmount}
- if(RCDIFF[0]<0&&FASTRCFF[0]<0){ return -tradeAmount} // over the top
- return 0
- }();
- MANUAL[0] = -1;
Add Comment
Please, Sign In to add comment