- UID
- 2
- 积分
- 2874604
- 威望
- 1387331 布
- 龙e币
- 1487273 刀
- 在线时间
- 13155 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-11-24
|
【LinReg2Periods】
- [LegacyColorValue = TRUE];
- inputs : Periods(20);
- vars : LRValueEnd(0),
- LRSlopeEnd(0),
- LRStdDevEnd(0),
- LRValueBeg(0),
- PlotBarsBack(0),
- LRChanWidth(0);
- LRValueEnd = LinearRegValue(close, Periods, 0);
- LRSlopeEnd = LinearRegSlope(close, Periods);
- LRStdDevEnd = stddev(close, Periods);
- {
- Print(file("X:\omega\i_LRPrc.log"),Date, BarNumber, " Close ", Close, "
- LRVal ", LRValueEnd, " LRSlp ", LRSlopeEnd, " LRStd ", LRStdDevEnd);
- }
- if date = LastCalcDate then begin
- {Plot end of last LR period)}
- PlotBarsBack = 0;
- LRChanWidth = (2 * LRStdDevEnd[PlotBarsBack]);
- plot1[PlotBarsBack](LRValueEnd[PlotBarsBack],"LRP Short");
- plot2[PlotBarsBack]((LRValueEnd + LRChanWidth)[PlotBarsBack],"LRP SUpper");
- plot3[PlotBarsBack]((LRValueEnd - LRChanWidth)[PlotBarsBack],"LRP SLower");
- {Plot begin of last LR period)}
- LRValueBeg = LRValueEnd[PlotBarsBack] + ((Periods-1) *
- (LRSlopeEnd[PlotBarsBack] * -1));
- PlotBarsBack = Periods - 1;
- plot1[PlotBarsBack](LRValueBeg, "LRP Short");
- plot2[PlotBarsBack]((LRValueBeg + LRChanWidth), "LRP SUpper");
- plot3[PlotBarsBack]((LRValueBeg - LRChanWidth), "LRP SLower");
- {Plot end of prev LR period)}
- plot4[Periods](LRValueEnd[Periods],"LRP S Prev");
- {Plot begin of last LR period)}
- LRValueBeg = LRValueEnd[Periods] + ((Periods-1) *
- (LRSlopeEnd[Periods] * -1));
- PlotBarsBack = (Periods * 2) - 1;
- plot4[PlotBarsBack](LRValueBeg, "LRP S Prev");
- end;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|