"Slow Stochastic crosses 80 and close < 10 day moving average. So far It is good.
BUT, in case stochastic comes below the OverBought zone(80), and close < 10 day moving average, my command won't execute because of " Slow Stochastic crosses 80 and " criteria.
So all in short, I want to find a way to close my position when slow stochastic first CROSSED 80 and ever since then,(even if stochastic comes below 80) if close < 10 day moving average, then close my position.
Thanks.
Code: Select all
inputs: Length( 14 ), OverSold( 20 );
variables: var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ) ;
Value1 = Stochastic( H, L, C, Length, 3, 3, 1, var0, var1, var2, var3 ) ;
condition1 = var2 crosses over Oversold and var2 <25 and XAverage(Close,50) > XAverage(Close,200) ;
if condition1 then
Buy ( "StochLE" ) this bar on close;
[b]////////////////////// ////////////////problem zone /////////////////////
condition2 = var2 crosses above 80;
if condition2 and close < Average(Close,10)
then
sell ( "StochLE_Profit_OUT" ) this bar on close ;
condition4 = var2 crosses over 30;
if condition4 and close < Average(Close,10)
then sell ( "StochLE_Profit_OUT1" ) this bar on close ;
///////////////////////////////////////////////////////////////////////[/b]