Instead of using $ and % as profit target, how can I make the program to close my short position when slow stochastic reaches less than equal to 50?
the code gets compiled but I don't seem to get any trades done.
Can someone please test this and adjust it to work?
Code: Select all
/// setting up profit close when slow stochastic reaches 50
[IntrabarOrderGeneration = false]
inputs: Amount( 5 ), PositionBasis( false ) ;
Vars: oFastK(0), oFastD(0), oSlowK(0), oSlowD(0);
Value1 = Stochastic(H, L, C, 14, 3, 3, 1, oFastK, oFastD, oSlowK, oSlowD);
if PositionBasis then
SetStopPosition
else
SetStopShare ;
if MarketPosition = 1 and value1 > 50 then
SetProfitTarget( Amount ) ;
Code: Select all
////////// shorting when slow stochastic closes below 80;
inputs: Length( 14 ), OverBought( 80 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ) ;
Value1 = Stochastic( H, L, C, Length, 3, 3, 1, var0, var1, var2, var3 ) ;
condition1 = CurrentBar > 2 and var2 crosses under var3 and var2 > OverBought ;
if condition1 then
Sell Short ( "StochSE" ) next bar at market ;