Missing buy/sell variable statements during backtest (amibroker)

#1
While doing backtest of the following script in amibroker, I get 'missing buy/sell variable assignment' error, though I have assigned buy/sell variables in the script.

****************************************************************

function isBuyCond()
return (C[BarCount-2] > O[BarCount-2]);

function isSellCond()

return (C[BarCount-2] <= O[BarCount-2]);

if (isSellCond())
Sell = 1;

if (isBuyCond())
Buy = 1;

****************************************************************

Basically with the above strategy, I am trying to generate buy/sell signals based on the last candle. If candle is green, then set BUY to True; if candle is red, set SELL to true.

Please let me know if I am missing something
 
#3
Thanks, it is not giving buy/sell variable error, I have two questions further:
1) Can't I backtest a strategy with buy/sell variables under if condition?
2) after doing suggested modification, I get only one entry in the backtest table, though I can visually expect multiple buy/sell trades. I believe that is because of 'Barcount-2' which is always referring to second last candle on the chart, though I am expecting to refer previous candle at every tick. Is there a way to take to do that in backtesting?
 

Similar threads