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

Re: Plz any body TS8 Stocastic Code conversion required for TS2000i



PureBytes Links

Trading Reference Links

Mr MUHAMMAD BABAR wrote:
> 
> Please any body can convert below TS8 Stocstic
> indicator for TS2000i. Full code with functions are
> given below. If you need any other function let me
> know and i will send you in few hours.

Hi Muhammad,

Muhammad, I think that there is some misunderstanding.  We are all here
to help each other - to assist each other in our own code writing
problems - to draw on each others expertise when we stumble on a problem
that, try as we might, we have not been able to solve.  I believe that
just about anyone here would try to help you in converting this code
from TS8 to TS2000i however, I don't believe that anyone is going to do
it for you.  Please understand what you're asking - you're not asking
for help in your conversion problem - your asking that someone convert
it for you.  Doing the work for you is not the same as helping you over
a problem area that you have in your code writing.

With that in mind I'll try and point you in the correct direction to get
you started on your conversion process.  Several of the functions that
you've listed are already part of the standard function set of TS 2000i
- that is, the names already exist in TS 2000i - however, the function
code that you listed is very different from that in the standard TS
2000i function of the same name.  It would seem that your first task is
to determine which way you want to go.  Re-name your TS8 functions and
change all the references to the new name - edit the existing TS 2000i
functions to include your new code - save the existing TS 2000i
functions with a different name and then use the TS8 names as new
functions.

The Stochastic, Extremes, and XAverageOig are new functions so they
should work as named.

The XAverage, Average, Cum, Highest, and Lowest already exist in TS
2000i so you will need to do some thing about these. 

So, it seems to me, that the first step you need to do is determine how
you are going to handle the naming problem.  Once you have the naming
problem worked out you can move on to any other problems. I did note one
in your Extremes Function. There is a value called "ExecOffset" - it has
not been defined.  It needs to be called out as an 'Input' or as a 'Var'
and a value must be assigned to it.

Larry

 
> INDICATOR CODE IN TS8 LANUGAGE
> 
> inputs:
>         PriceH( High ),
>         PriceL( Low ),
>         PriceC( Close ),
>         StochLength( 5 ),
>         SmoothingLength1( 5 ), { used to slow FastK to FastD
> = SlowK }
>         SmoothingLength2( 2 ), { used to slow FastD to SlowD
> }
>         SmoothingType( 1 ), { pass in 1 for Original, 2 for
> Legacy }
>         OverSold( 20 ),
>         OverBought( 80 ),
>         OverSColor( Green ),
>         OverBColor( Red );
> 
> variables:
>         oFastK( 0 ),
>         oFastD( 0 ),
>         oSlowK( 0 ),
>         oSlowD( 0 );
> 
> 
> Value1 = Stochastic(
>         PriceH,
>         PriceL,
>         PriceC,
>         StochLength,
>         SmoothingLength1,
>         SmoothingLength2,
>         SmoothingType,
>         oFastK,
>         oFastD,
>         oSlowK,
>         oSlowD ) ;
> 
> Plot1( oSlowD, "SlowD", Cyan );
> Plot2 (OverSold, "OverSld");
> Plot3(OverBought, "OverBot");
> 
> { Color criteria }
> if Plot1 > OverBought then
>         SetPlotColor( 1, OverBColor )
> else if Plot1 < OverSold then
>         SetPlotColor( 1, OverSColor ) ;
> 
> { Alert criteria }
> if Plot1 crosses over OverSold then
>         Alert( "Indicator exiting oversold zone" )
> else if Plot1 crosses under OverBought then
>         Alert( "Indicator exiting overbought zone" ) ;
> 
> FUNCTIONS
> 
> STOCASTIC FUNCTION
> 
> inputs:
>         PriceH( numericseries ),
>         PriceL( numericseries ),
>         PriceC( numericseries ),
>         StochLength( numericsimple ),
>         Length1( numericsimple ), { this input assumed to be
> a constant > 0; used to slow
>          FastK to FastD = SlowK }
>         Length2( numericsimple ), { this input assumed to be
> a constant > 0; used to slow
>          FastD to SlowD }
>         SmoothingType( numericsimple ), { this input is
> assumed to be constant; pass in 1
>          for Original, 2 for Legacy }
>         oFastK( numericref ),
>         oFastD( numericref ),
>         oSlowK( numericref ),
>         oSlowD( numericref ) ;
> 
> variables:
>         LL( 0 ), { lowest low }
>         HH( 0 ), { highest high }
>         Num1( 0 ), { numerator 1 }
>         Den1( 0 ), { denominator 1 }
>         Num2( 0 ), { numerator 2 }
>         Den2( 0 ), { denominator 2 }
>         BarsToGo1( 0 ),
>         BarsToGo2( 0 ) ;
> 
> Stochastic = 1 ;
> 
> LL = Lowest( PriceL, StochLength ) ;
> HH = Highest( PriceH, StochLength ) ;
> Num1 = PriceC - LL ;
> Den1 = HH - LL ;
> 
> if Den1 > 0 then
>         oFastK = Num1 / Den1 * 100
> else
>         begin
>         oFastK = 0 ;
>         Stochastic = -1 ;
>         end ;
> 
> if SmoothingType = 1 then { Original }
>         begin
>         BarsToGo1 = Length1 - CurrentBar ;
>         if BarsToGo1 > 0 then
>                 begin
>                 { use approximate "backpropagated" calculations
> until we have enough data }
>                 Num2 = ( Cum( Num1 ) + BarsToGo1 * Num1[ CurrentBar
> - 1 ] ) / Length1 ;
>                 Den2 = ( Cum( Den1 ) + BarsToGo1 * Den1[ CurrentBar
> - 1 ] ) / Length1 ;
>                 end
>         else
>                 begin
>                 Num2 = Average( Num1, Length1 ) ;
>                 Den2 = Average( Den1, Length1 ) ;
>                 end ;
>         if Den2 > 0 then
>                 oFastD = Num2 / Den2 * 100
>         else
>                 begin
>                 oFastD = 0 ;
>                 Stochastic = -1 ;
>                 end ;
>         BarsToGo2 = Length2 - CurrentBar ;
>         if BarsToGo2 > 0 then
>                 { use approximate "backpropagated" calculations
> until we have enough data }
>                 oSlowD = ( Cum( oFastD ) + BarsToGo2 * oFastD[
> CurrentBar - 1 ] ) / Length2
>         else
>                 oSlowD = Average( oFastD, Length2 ) ;
>         end
> else if SmoothingType = 2 then { Legacy }
>         begin
>         oFastD = XAverage( oFastK, Length1 ) ;
>         oSlowD = XAverageOrig( oFastD, Length2 ) ;
>         end ;
> 
> oSlowK = oFastD ;
> 
> LOWEST FUNCTION
> 
> inputs: Price( numericseries ), Length( numericsimple
> ) ;
> variables: oExtremeVal( 0 ), oExtremeBar( 0 ) ;
> 
> Value1 = Extremes( Price, Length, -1, oExtremeVal,
> oExtremeBar ) ;
> 
> Lowest = oExtremeVal ;
> 
> EXTREMES FUNCTION
> 
> inputs:
>         Price( numericseries ),
>         Length( numericsimple ),
>         HiLo( numericsimple ), { pass in 1 for Highest(Bar),
> -1 for Lowest(Bar) }
>         oExtremeVal( numericref ),
>         oExtremeBar( numericref ) ;
> 
> variables:
>         MyVal( 0 ),
>         MyBar( 0 ) ;
> 
> MyVal = Price ;
> MyBar = 0 ;
> 
> for Value1 = 1 to Length - 1
>         begin
>         if ( HiLo = 1 and Price[Value1] > MyVal )
>                 or ( HiLo = -1 and Price[Value1] < MyVal )
>         then
>                 begin
>                 MyVal = Price[Value1] ;
>                 MyBar = Value1 ;
>                 end ;
>         end ;
> 
> oExtremeVal = MyVal ;
> oExtremeBar = MyBar + ExecOffset ;
> 
> Extremes = 1 ;
> 
> HIGHEST FUNCTION
> 
> inputs: Price( numericseries ), Length( numericsimple
> ) ;
> variables: oExtremeVal( 0 ), oExtremeBar( 0 ) ;
> 
> Value1 = Extremes( Price, Length, 1, oExtremeVal,
> oExtremeBar ) ;
> 
> Highest = oExtremeVal ;
> 
> CUM FUNCTION
> 
> inputs: Price( numericseries ) ;
> 
> Cum = Cum[1] + Price ;
> 
> AVERAGE FUNCTION
> 
> inputs:
>         Price( numericseries ),
>         Length( numericsimple ) ; { will get divide-by-zero
> error if Length = 0 }
> 
> Average = Summation( Price, Length ) / Length ;
> 
> XAVERAGE FUNCTION
> 
> inputs:
>         Price( numericseries ),
>         Length( numericsimple ) ; { this input assumed to be
> a constant >= 1 }
> 
> variables:
>         SmoothingFactor( 2 / ( Length + 1 ) ) ;
> 
> if CurrentBar = 1 then
>         XAverage = Price
> else
>         XAverage = XAverage[1] + SmoothingFactor * ( Price -
> XAverage[1] ) ;
> 
> XAVERAGEOIG FUNCTION
> 
> inputs:
>         Price( numericseries ),
>         Length( numericsimple ) ; { this input assumed to be
> a constant >= 1 }
> 
> variables:
>         SmoothingFactor( 1 / Length ) ;
> 
> if CurrentBar = 1 then
>         XAverageOrig = Price
> else
>         XAverageOrig = XAverageOrig[1] + SmoothingFactor * (
> Price - XAverageOrig[1] ) ;
> 
> 
> __________________________________________