Small Help in Coding ERROR

#1
Please help me out with what corrections need to be done in the code below as i am not getting the desired result.

Result required is:
Buy when condition 1 is true and sell with condition sell1 (when the buy signal generated was with condition 1)
Buy when condition 2 is true and sell with condition sell2 (when the buy signal generated was with condition 2)

Buy=sell=null;
Bflag=0;

for(i=0;i<BarCount;i++)
{

if ( condition1[ i ]==1 AND Bflag==0)
{
Buy= condition1;
bflag = 1;
BuyPrice[ i ] =Close[ i ];

}

if( sell1==1 AND bflag == 1)
{
Sell= sell1;
SellPrice= Close;
Bflag=0;
}

if ( Condition2[ i ]==1 AND Bflag==0)
{
Buy= Condition2;
bflag = 2;
BuyPrice[ i ] =Close[ i ];
}
if(Sell2==1 AND bflag == 2)
{
Sell= Sell2;
SellPrice= Close;
Bflag=0;
}
}
 

Similar threads