Board logo

标题: [TS源码] R-Breaker策略[TradeStation源码] [打印本页]

作者: 龙听    时间: 2018-3-24 10:26     标题: R-Breaker策略[TradeStation源码]

R-Breaker策略[TradeStation源码]:
  1. {R-Breaker}
  2. {***********SystemSetup*******************
  3. Trading between 9:15 and 14:29 ChicagoTime only
  4. MMStop $1000
  5. Close End of Day
  6. 10 min Time Frame
  7. ******************************************}


  8. input:notbef(715),notaft(1229);
  9. var:{input:}f1(.35),f2(0.07),f3(.25),reverse(2.00),
  10. rangemin(1.15),xdiv(3);

  11. var:ssetup(0),bsetup(0),senter(0),benter(0),bbreak(0),sbreak(0),
  12. ltoday(0),hitoday(9999),startnow(0),div(0),
  13. rfilter(false);


  14. if currentbar=1 then startnow=0;
  15. div=maxlist(xdiv,1);
  16. if d>d[1] then begin

  17. startnow=startnow+1;

  18. ssetup=hitoday[1]+f1*(c[1]-ltoday[1]);
  19. senter=((1+f2)/2)*(hitoday[1]+c[1])-(f2)*ltoday[1];
  20. benter=((1+f2)/2)*(ltoday[1]+c[1])-(f2)*hitoday[1];
  21. bsetup=ltoday[1]-f1*(hitoday[1]-c[1]);
  22. bbreak=ssetup+f3*(ssetup-bsetup){(1.3625*hitoday[1]+.45*c[1])-.8125*ltoday[1]};
  23. sbreak=bsetup-f3*(ssetup-bsetup){(1.3625*ltoday[1]+.45*c[1])-.8125*hitoday[1]};

  24. hitoday=h;
  25. ltoday=l;

  26. rfilter=hitoday[1]-ltoday[1]>=rangemin;

  27. end;

  28. if h>hitoday then hitoday=h;
  29. if l<ltoday then ltoday=l;

  30. if t>=notbef and t<notaft and startnow>=2 and rfilter and
  31. date>entrydate(1) then begin

  32. if hitoday>=ssetup and marketposition>-1 then
  33. SELL("Rlev SE") senter+(hitoday-ssetup)/div stop;
  34. if ltoday<=bsetup and marketposition<1 then
  35. BUY("Rlev LE") benter-(bsetup-ltoday)/div stop;

  36. if marketposition=-1 then
  37. BUY("RbUP LE") entryprice+reverse stop;
  38. if marketposition=1 then
  39. SELL("RbDN SE") entryprice-reverse stop;

  40. if marketposition=0 then
  41. BUY("Break LE") bbreak stop;
  42. if marketposition=0 then
  43. SELL("Break SE") sbreak stop;

  44. end;

  45. if t>=notaft and t<>sess1endtime then begin

  46. if marketposition=-1 then
  47. EXITSHORT("RbUP SX") entryprice+reverse stop;
  48. if marketposition=1 then
  49. EXITLONG("RbDN LX") entryprice-reverse stop;

  50. EXITSHORT("Late SX") h+.05 stop;
  51. EXITLONG("Late LX") l-.05 stop;
  52. END;
复制代码

作者: 龙听小虎    时间: 2023-11-4 21:01






欢迎光临 龙听期货论坛 (http://www.qhlt.cn/) Powered by Discuz! 7.2