Guest User

Untitled

a guest
Jan 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. // Rudolf algo Tom
  2. index = BNCE_XBTUSD;
  3. magnTresh = index[0]/500 // start trading from this drop magnitude
  4. magnSpeed = magnTresh/100 // minimal consistent change per second
  5.  
  6. function rc(t, x){
  7. x = x.slice(0,t+1); s = 0;
  8. for(j=0;j<x.length-1;j++){
  9. s += x[j]-x[j+1];
  10. }
  11. return s / x.length;
  12. }
  13.  
  14. function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }
  15. function dirCount(f, s){
  16. dir = sign(f[0]-s[0]);
  17. count = 0; end = f[0]; magn = 0
  18. for(i=0;i<f.length;i++){
  19. if(sign(f[i]-s[i])!=dir){magn = end-f[i]; break;}else{count++;}
  20. }
  21. return [count, magn];
  22. }
  23.  
  24. function sma(t, xc){
  25. som=0; xc=xc.slice(0,t);
  26. for(i=0;i<xc.length;i++){som+=xc[i];}
  27. return som/xc.length;
  28. }
  29.  
  30. FAST[0] = sma(10, index)
  31. SLOW[0] = sma(30, index)
  32.  
  33. FASTRC[0] = rc(30, FAST);
  34. FASTRCF[0] = rc(10, FAST);
  35. FASTRCFF[0] = rc(3, FAST);
  36. RCDIFF[0] = FASTRCF[0]-FASTRC[0];
  37. FASTRCFFRC[0] = rc(3, FASTRCFF);
  38.  
  39. dir = dirCount(FAST, SLOW);
  40. DIRTIME[0] = dir[0];
  41. DIRMAGN[0] = dir[1];
  42.  
  43. if(DIRMAGN[0]<-magnTresh&&DIRMAGN[0]<-DIRTIME[0]*magnSpeed){mark("m")}
  44.  
  45. DROPREBOUND[0] = function(){
  46. if((FAST[0]<SLOW[(DIRTIME[0]*2)]+(DIRMAGN[0]*0.7)) // should really be a long term drop, not a peak
  47. &&(DIRMAGN[0]<-magnTresh&&DIRMAGN[0]<-DIRTIME[0]*magnSpeed)
  48. &&RCDIFF[0]>0&&FASTRCF[0]>0&&FASTRCFFRC[0]>0&&FAST[0]<SLOW[0]){ return 1}
  49. if(RCDIFF[0]<0&&FASTRCFF[0]<0){ return -1} // over the top
  50. return 0
  51. }();
Add Comment
Please, Sign In to add comment