I want to sell in the second profitable opening, but I can't get the code to work, when I add "AND BarsSince(Buy) >= 2" or "&& BarsSince(Buy) >= 2" it doesn't work anywhere....
Where would you put it?
//EXIT WITH FIRST PROFITABLE OPENING bullish
priceatbuy = 0; bi = BarIndex();
for( i = 0; i < BarCount; i++ )
{
if( priceatbuy == 0 && Buy[ i ] ) //First buy
{
priceatbuy = BuyPrice[ i ]; //price buy
stopprice = priceatbuy - priceatbuy*0.05; //stop loss price
EntryBar = bi[ i ]; //BAR WHERE WE BUY
}
if( priceatbuy > 0 && bi[ i ] > EntryBar && Open[ i ] > priceatbuy ) //IF BUY AND First Profit Opening
{
Sell[ i ] = 1 AND BarsSince(Buy) >= 2;
SellPrice[ i ] = Open[i];
priceatbuy = 0;
}
else if( priceatbuy > 0 && Low[ i ] < stopprice ) //IFSTOP LOSS
{
Sell[ i ] = 1;
Buy [ i ] = 0; //IF IT IS TIME TO SELL WE CANNOT BUY
SellPrice[ i ] = stopprice;
priceatbuy = 0;
}
else
Sell[ i ] = 0;
}