[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

need help with writing a showme



PureBytes Links

Trading Reference Links

Could someone help with writing a showme for TS2000i?  How do you use an 
indicator as a condition in a formula for a show me?  I have done it 
using the fastK function, but it does not match the stoch I am using 
which is not  a stoch that comes with TS2000i. Do I have to make the 
indicator into a function? If so how would I do that? Below is the stoch 
formula I am using.

inputs:
   PriceH( High ), 
   PriceL( Low ),
   PriceC( Close ),
   StochLength( 27 ),
   SmoothingLength1( 9 ), { used to slow FastK to FastD = SlowK }
   SmoothingLength2( 9 ), { used to slow FastD to SlowD }
   SmoothingType( 1 ), { pass in 1 for Original, 2 for Legacy }
   OverSold( 20 ),
   OverBought( 80 ) ;

variables:
   oFastK( 0 ),
   oFastD( 0 ),
   oSlowK( 0 ),
   oSlowD( 0 ) ;

{
 The Stochastic method does not exist in TradeStation 5, and
 the code from TradeStation 6 does not work in TradeStation 5.
Value1 = Stochastic(
   PriceH, 
   PriceL,
   PriceC,
   StochLength,
   SmoothingLength1,
   SmoothingLength2,
   SmoothingType,
   oFastK,
   oFastD,
   oSlowK,
   oSlowD ) ;
}

{--------------  The following replaces the Stochastic() method  ---------}
{--------------  from TradeStation 6                             ---------}

Vars  :  LL        (00), { lowest low }
        HH        (00), { highest high }
        Num1      (00), { numerator 1 }
        Den1      (00), { denominator 1 }
        Num2      (00), { numerator 2 }
        Den2      (00), { denominator 2 }
        BarsToGo1 (00),
        BarsToGo2 (00) ;

LL    = Lowest  (PriceL, StochLength) ;
HH    = Highest (PriceH, StochLength) ;
Num1  = PriceC - LL ;
Den1  = HH - LL ;

if Den1 > 0
then  oFastK = Num1 / Den1 * 100
else  oFastK = 0 ;

if SmoothingType = 1 then { Original }
begin
  BarsToGo1 = SmoothingLength1 - CurrentBar ;
  if  BarsToGo1  > 0 then begin
    Num2 = (@Cum (Num1) + BarsToGo1 * Num1[ CurrentBar - 1 ] ) / 
SmoothingLength1 ;
    Den2 = (@Cum (Den1) + BarsToGo1 * Den1[ CurrentBar - 1 ] ) / 
SmoothingLength1 ;
  end
  else begin
    Num2 = @Average (Num1, SmoothingLength1) ;
    Den2 = @Average (Den1, SmoothingLength1) ;
  end ;

  if Den2  > 00
  then oFastD = Num2 / Den2 * 100
  else oFastD = 0 ;

  BarsToGo2 = SmoothingLength2 - CurrentBar ;

  if BarsToGo2 > 0
  then  oSlowD = (@Cum (oFastD) + BarsToGo2 * oFastD[CurrentBar - 01] ) 
/ SmoothingLength2
  else  oSlowD = @Average (oFastD, SmoothingLength2) ;
end
else
if  SmoothingType = 2  { Legacy }
then begin
  oFastD  = @XAverage     (oFastK, SmoothingLength1) ;
  oSlowD  = @XAverageOrig (oFastD, SmoothingLength2) ;
end ;
oSlowK = oFastD ;

{-----------------------------------------------------------------------}


Plot1( oSlowK, "SlowK" ) ;
Plot2( oSlowD, "SlowD") ;
Plot3( OverSold, "OverSld" ) ;
Plot4( OverBought, "OverBot" ) ;

if plot1 > plot1[1] then setplotcolor(1, green);
if plot1 < plot1[1] then setplotcolor(1, red);

{ Alert criteria }
if Plot2 crosses over OverSold then
   Alert( "SlowD exiting oversold zone" )
else if Plot2 crosses under OverBought then
   Alert( "SlowD exiting overbought zone" ) ;


{ ** Copyright (c) 1991-2001 TradeStation Technologies, Inc. All rights 
reserved. ** }