Board logo

标题: [TS源码] Predicting an Event [EasyLanguage Code] [打印本页]

作者: 龙听    时间: 2021-3-4 16:43     标题: Predicting an Event [EasyLanguage Code]

EasyLanguage Code To TesT The Predictability Of An Event
本帖隐藏的内容需要回复才可以浏览
  1. Vars:
  2.         Event(false),
  3.         FuturePrice(0),
  4.         I(0),
  5.         CG(0),
  6.         Denom(0);

  7. Arrays:
  8.         PredictBin[100](0);

  9. {>>>>>>>>> Code for Event Goes Here <<<<<<<<<<}

  10. If Event Then Begin
  11.         FuturePrice = 100*(Close - Close[9]) / Close[9];        //Future is referenced to 10 bars back
  12.         If FuturePrice < -10 Then FuturePrice = -10;        //Limits lower price to -10%
  13.         If FuturePrice > 10 Then FuturePrice = 10;        //Limits higher price to +10%
  14.         FuturePrice = 5*(FuturePrice + 10);        //scale -10% to +10% to be 0 - 100
  15. End;
  16. //Place the FuturePrices into one of 100 bins
  17. If FuturePrice <> FuturePrice[1] Then Begin
  18.         For I = 1 to 100 Begin
  19.                 If FuturePrice > I - 1 and FuturePrice <= I Then PredictBin[I] = PredictBin[I] + 1;
  20.         End;
  21. End;
  22. //Measure center of gravity as a quick estimate
  23. CG = 0;
  24. Denom = 0;
  25. For I = 1 to 100 Begin
  26.         CG = CG + I*PredictBin[I];
  27.         Denom = Denom + PredictBin[I];
  28. End;
  29. CG = (CG/Denom-50)/5;

  30. Plot1(CG);

  31. If LastBarOnChart Then Begin
  32.         For I = 0 to 100 Begin
  33.                 Print(File("C:\PDFTest\PDF.CSV"), .2*I - 10, ",", PredictBin[I]);
  34.         End;
  35. End;
复制代码

作者: 马弘立    时间: 2021-8-26 17:04

学习




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