TS Stochastic Crossover Strategy Code Help?

clbradley17

Junior member
Messages
25
Likes
0
Have a Stochastic Crossover Strategy Code for Tradestation that I need help with please. I need to add conditions that the stochastic slow k went to either less than 10 or just less than oversold before crossing back above the oversold line of 20 before buying, and also the opposite, that it got to 90 before crossing back under the overbought level of 80 before selling short. Guess it needs 4 conditions, if 1, then 2 are met, then buy, and if 3 then 4 are met, sell short. Here is the Stochastic Crossover Strategy code so far:

inputs:
PriceH( High ),
PriceL( Low ),
PriceC( Close ),
StochLength( 14 ),
SmoothingLength1( 3 ),
SmoothingLength2( 3 ),
SmoothingType( 1 ).
Oversold( 20 ),
Overbought( 80 ) ;

variables:
FastK( 0 ).
FastD( 0 ),
SlowK( 0 ),
SlowD( 0 ) ;

Value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, FastK, FastD, SlowK, SlowD ) ;

If SlowK crosses over SlowD
Then buy 1 share next bar at market;

If SlowK crosses under SlowD
Then sell short 1 share next bar at market;


Thanks for any help.

Curtis
 
// Declare two boolean variables:
vars: bool touched10(false), bool touched90(false);

If slowk < = 10 then touched10 = true;

If slowk > = 90 then touched90 = true;

if slowk crosses under 80 and touched90 = true then begin
sell.....
touched90 = false;
end;

if slowk crosses over 20 and touched10 = true then begin
buy .....
touched10 = false;
end;


Hope this helps.

Mark C.





Have a Stochastic Crossover Strategy Code for Tradestation that I need help with please. I need to add conditions that the stochastic slow k went to either less than 10 or just less than oversold before crossing back above the oversold line of 20 before buying, and also the opposite, that it got to 90 before crossing back under the overbought level of 80 before selling short. Guess it needs 4 conditions, if 1, then 2 are met, then buy, and if 3 then 4 are met, sell short. Here is the Stochastic Crossover Strategy code so far:

inputs:
PriceH( High ),
PriceL( Low ),
PriceC( Close ),
StochLength( 14 ),
SmoothingLength1( 3 ),
SmoothingLength2( 3 ),
SmoothingType( 1 ).
Oversold( 20 ),
Overbought( 80 ) ;

variables:
FastK( 0 ).
FastD( 0 ),
SlowK( 0 ),
SlowD( 0 ) ;

Value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, FastK, FastD, SlowK, SlowD ) ;

If SlowK crosses over SlowD
Then buy 1 share next bar at market;

If SlowK crosses under SlowD
Then sell short 1 share next bar at market;


Thanks for any help.

Curtis
 
Top