I am trying to develop a strategy in quanstrat that buys when the QQQ is greater than the SMA 200 and sells when the SMA 200 is less than the QQQ. But there is a propblem with my buy and sell signals .
This is the error
Error in sigComparison(label = label, data = data, columns = columns[c(i, : comparison of more than two columns not supported, see sigFormula
Current code is below:
add.indicator(strategy=tr1.st2,name='SMA',
arguments=list(x=quote(Cl(mktdata)),n=200),label='SMA 200')
Add Buying and Selling Signals
add.signal(strategy=tr1.st2,
name='sigThreshold',
arguments=list(threshold=200,column='SMA',relationship='lt'),
label='BuySignal')
add.signal(strategy=tr1.st2,
name='sigThreshold',
arguments=list(threshold=200,column='SMA',relationship='gt'),
label='SellSignal')
Add Enter and Exit Rules
addPosLimit(portfolio=tr1.st2,
symbol='QQQ',
timestamp=start.date,maxpos=10)
add.rule(strategy=tr1.st2,
name='ruleSignal',
arguments=list(sigcol='BuySignal',sigval=T,orderqty=10,
osFUN=osMaxPos,ordertype='market',orderside='long'),
type='enter',
label='EnterRule',enabled=T)
add.rule(strategy=tr1.st2,
name='ruleSignal',
arguments=list(sigcol='SellSignal',sigval=T,orderqty='all',ordertype='market',orderside='long',TxnFees=-6),
type='exit',label='ExitRule',enabled=T)