I need help to improve my system

#1
Im the new member of this forum so hello everyone! :)

Few days ago i built a system but i need help to improve this one.

I don't know how to change formula that cond4 will not clashes with cond 5...
I want Trailing stop to start only if cond3 will take a place if not cond5 appears.
I've spent hours on this but i can't do that :|
Can sbd help me, please? :(

Cond3=StochK(14,5)>90;
Cond4=ApplyStop(2,2,40,2);
Cond5=StochD( 14, 4, 5 ) > StochK( 14, 5 );

Sell=0;

function _IIf( Cond3, Cond4, Cond5)
{
for( i = 0; i < BarCount; i++ );
{
if( Cond3[ i ] );
{
result[ i ] = Cond4[ i ];
}
if(Cond3=Null);
{
result=Cond5;
}
}
}