door Paul M » di 12 aug 2003, 19:35
Hallo Geert,
Bedankt voor de snelle reactie.
Maar ze ?zijn het volgens mij niet. ?Ik kwam onderstaande code tegen en daar wordt aan het eind, bij value1 =, de functie Stochastic aangeroepen.
Volgens de help Topics van Tradestation-Pro moet het een functie zijn met volgende parameters.
Function
Stochastic(PriceH, PriceL, PriceC, StochLength, SmoothingLength1, SmoothingLength2, SmoothingType, oFastK, oFastD, oSlowK, oSlowD)
Code:
{
A Smoother Stochastic-RSI
7/21/2003
aspTrader @ TradestationWorld
With thanks to:
- ?Tushar Chande for the idea of plotting a stochastic against the RSI
? AND for the Ravi indicator
- ?? Tillson for T3
- ?Bob Fulks for posting the code for T3 back in 12/1997
- ?Mark Jurik for multiple terrific ideas about creating dynamically adjusted indicators.
}
inputs:
PriceSmoothLength(2),
RaviFastLength(5),
RaviSlowLength(55),
LowRaviLimit(5),
HighRaviLimit(25),
RSILookbackSmoothLength(8),
StochLookbackSmoothLength(8),
LowStochLimit(13),
HighStochLimit(34),
StochSmoothLength1(2),
StochSmoothLength2(2);
variables:
Price(0),
RaviFastValue(0),
RaviSlowValue(0),
Ravi(0),
MaxRavi(2),
MinRavi(10),
RaviStochastic(0),
Depth(0),
RSILookbackLength(0),
DynamicRSI(0),
StochLookbackLength(0),
oFastK( 0 ),
oFastD( 0 ),
oSlowK( 0 ),
oSlowD( 0 ),
StochSmoothingType(1); { pass in 1 for Original, 2 for Legacy }
{ Smooth the price before doing anything... }
Price = T3Average( ( high + low + close + close ) / 4, PriceSmoothLength );
{ Compute Ravi }
RaviFastValue = T3Average( Price, RaviFastLength );
RaviSlowValue = T3Average( Price, RaviSlowLength );
Ravi = absvalue( 100 * ( RaviFastValue - RaviSlowValue ) / RaviSlowLength );
{ Compute maximum and minimum Ravi values and then compute a Stochastic of Ravi }
if Ravi > MaxRavi then
MaxRavi = Ravi
else ifRavi < MinRavi then
MinRavi = Ravi;
RaviStochastic = ( Ravi - MinRavi ) / ( MaxRavi - MinRavi ) ;
{ Compute a dynamic lookback period length for the RSI }
Depth = ceiling( LowRaviLimit + RaviStochastic * (HighRaviLimit - LowRaviLimit) ) ;
RSILookbackLength = T3Average( Depth, RSILookbackSmoothLength );
{ Compute the value of a dynamic RSI }
DynamicRSI = T3Average( RSI( Price, RSILookbackLength), RSILookbackLength ) ;
{ The formula above is a substitute for the BETTER DynamicRSI that requires
?the use of Mark Jurik's RSX indicator as computed below.
? ? See <a href="http://www.jurikres.com" target="_blank">www.jurikres.com</a> for more info. }
?{DynamicRSI = JRC.RSX.flex.2k( Price, RSILookbackLength) ;}
{ Compute a dynamic lookback period length for the Stochastic }
Depth = ceiling( LowStochLimit + RaviStochastic * ( HighStochLimit - LowStochLimit) );
StochLookbackLength = T3Average( Depth, StochLookbackSmoothLength );
{ Compute and plot a Stochastic of the DynamicRSI }
Value1 =
Stochastic(
DynamicRSI, ?
DynamicRSI,
DynamicRSI,
StochLookbackLength,
StochSmoothLength1,
StochSmoothLength2,
StochSmoothingType,
oFastK,
oFastD,
oSlowK,
oSlowD ) ;
plot1(oFastK, "StochRSI" );
Paul