|
|||||||||||||||||||
|
|||||||||||||||||||
| Special offer: buy MetaStock (try for free) | Reuters QuoteCenter Real-Time Data (get a free month) | EOD Data |
|
1) estimates of next price(s) 2) price envelopes and/or channels 3) moving average replacements Type : Function, Name : NLR { NLR Function WAV 11/28/03 NonLinear Regression Analysis y = A + B*X + C*X*X (2nd order) y price x bar (time) A,B,C coefficients to determine Standard deviation (S) of price from calculated price for length data is returned price for desired bar (either a past or future one) is returned } InPuts: Length(NumericSimple), price(NumericSeries), DesiredBar(NumericSimple),oNLRPrice(NumericRef),oStdDev(NumericRef); vars: AvgX(0),AvgY(0),N(0),XM(0),YM(0),XM2(0),SXX(0),SXY(0),SYY(0), SSYY(0),SXX2(0),SX2X2(0),SYX2(0),ACoeff(0),BCoeff(0),CCoeff(0), X(0),Y(0), MaxLength(100),s(0),TX(0),TY(0),RV(0),ERR(0); array: YValue[100](0),XValue[100](0); if BarNumber = 1 then begin N = length; { be sure array size is protected } if N > MaxLength then N = MaxLength; if N < 2 then N = 2; end; { fill arrays } for value1 = 1 to N begin XValue[value1] = value1-1; YValue[value1] = Price[value1-1]; end; { calc averages of x,y pairs } AvgX = 0; AvgY = 0; for value1 = 1 to N begin AvgX = AvgX + XValue[value1]; AvgY = AvgY + YValue[value1]; end; if N <> 0 then begin AvgX = AvgX / N; AvgY = AvgY / N; end; { do regression and calc 3 coefficients } SXX = 0; SXY = 0;SYY = 0;SXX2 = 0;SX2X2 = 0;SYX2 = 0; for value1 = 1 to N begin XM = XValue[value1] - AvgX; YM = YValue[value1] - AvgY; XM2 = XValue[value1]*XValue[value1] - AvgX*AvgX; SXX = SXX + XM*XM; SXY = SXY + XM*YM; SYY = SYY + YM*YM; SXX2 = SXX2 + XM*XM2; SX2X2 = SX2X2 + XM2*XM2; SYX2 = SYX2 + YM*XM2; end; value99 = SXX*SX2X2 - SXX2*SXX2; if value99 <> 0 then begin BCoeff = ( SXY*SX2X2 - SYX2*SXX2 ) / value99 ; CCoeff = ( SXX*SYX2 - SXX2*SXY ) / value99; end; ACoeff = AvgY - BCoeff*AvgX - CCoeff*AvgX*AvgX; {calc estimated price for desired bar DesiredBar: use + for past and - for future eg., for next bar in future: DesiredBar = -1 } oNLRPrice = ACoeff + BCoeff*DesiredBar+ CCoeff*DesiredBar*DesiredBar; {calc std dev} S = 0; AvgY = 0; for value1 = 1 to N begin TY = YValue[value1]; TX = XValue[value1]; RV = ACoeff + BCoeff*XValue[value1]+ CCoeff*XValue[value1]*XValue[value1]; ERR = TY - RV; AvgY = AvgY + TY; S = S + ERR*ERR; end; if N-1 <> 0 then if S /(N-1) > 0 then S = SquareRoot(S /(N-1)); oStdDev = s; NLR = 1; The standard deviation of price versus calculated price (from NLR curve data) is easily determined. Interestingly, when the price calculation is close to the actual for several bars in a row (ie., low std dev) a significant price move sometimes occurs soon after demonstrating a possible new volatility measurement. See pic below for paintbar examples. Code has been updated to use the new NLR function. Type : Indicator, Name : NLR1 Indicator { NLR1 Indicator WAV 11/26/03 NonLinear Regression Analysis y = A + B*X + C*X*X (2nd order) y price x bar (time) A,B,C coefficients to determine modified 11/29 utilize NLR function added price input removed mult input plots only last bar from curve } InPuts: Length(20), price(close); vars: S(0),oNLRPrice(0); value1 = NLR(length, price, 0, oNLRPrice, S); plot1(oNLRPrice, "NLR"); Code:
all formulas for TradeStation all formulas
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators and systems are submitted by anonymous users. Therefore S4T™ does not take any responsibility for it's quality. If you use any of this information, use it at your own risk. You are responsible for your own trading decisions. Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade. In no case will S4T™ be responsible for your trading gains or losses. |
|
|