Guest User

Untitled

a guest
Jan 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. // TRADES ON DROP REBOUNDS
  2. index = BNCE_XBTUSD;
  3. tradeAmount = 0.003; // amount to trade
  4. magnSpeed = 0.00002; // 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. minMagn = DIRTIME[0]*magnSpeed*index[0];
  44. //if(DIRMAGN[0]<-7&&DIRMAGN[0]<-minMagn){mark("m")}
  45.  
  46. DROPREBOUND[0] = function(){
  47. if((FAST[0]<SLOW[(DIRTIME[0]*2)]+(DIRMAGN[0]*0.7)) // should really be a long term drop, not a peak
  48. &&(DIRMAGN[0]<-7&&DIRMAGN[0]<-minMagn)
  49. &&RCDIFF[0]>0.1&&FASTRCF[0]>0&&FASTRCFFRC[0]>0&&FAST[0]<SLOW[0]){ return tradeAmount}
  50. if(RCDIFF[0]<0&&FASTRCFF[0]<0){ return -tradeAmount} // over the top
  51. return 0
  52. }();
  53. MANUAL[0] = -1;
Add Comment
Please, Sign In to add comment