title: Keep getting the "dims do not match the length of object" in quantstrat
body: <p>I have been modifying a backtest I made a few months ago using quantstrat. It was all working fine until I added in signal and rule 6 (donchian channel low)
  My full code is below. Any help would be greatly appreciated.</p>
  
  <p>Thanks in advance.</p>
  
  <p>PS: Sorry if the code looks messy, this is my first time asking a question here.</p>
  
  <pre><code>library(blotter)
  library(quantstrat)
  library(xts)
  library(quantmod)
  Sys.setenv(TZ="UTC") 
  
  getSymbols('^DJI', from="2016-01-01", to="2016-12-31", index.class="POSIXct", adjust=T)
  
  
  colnames(DJI)&lt;- c("Open","High","Low","Close","Volume","Adjusted")
  
  currency("AUD") 
  Sys.setenv(TZ="UTC") 
  initdate &lt;- '2016-01-03' 
  startdate &lt;- '2016-01-04' 
  enddate &lt;- '2016-12-30'
  portfolioname &lt;- "Dow Jones" 
  accountname &lt;- "Dow Jones" 
  contracts &lt;- 1 
  txncost &lt;- -0.79 
  margin &lt;- 15000
  strategyname &lt;- accountname
  startingcapital &lt;- 1e+6
  symbollist &lt;- 'DJI'
  instrument&lt;-"DJI"
  
  
  rm.strat(strategyname) 
  initPortf(portfolioname,
        symbollist,initDate=initdate,currency="AUD")
  initAcct(accountname,portfolios=portfolioname,initDate=initdate,initEq=startingcapital,currency="AUD")
  initOrders(portfolio=portfolioname,initDate=initdate)
  strategy(strategyname,store=TRUE)
  strat &lt;- getStrategy(strategyname)
  summary(strat)
  
  
  osInvestAll &lt;- function (data, timestamp, orderqty, ordertype, orderside, equity, portfolio, symbol, ruletype, ..., orderprice) 
  {   
  datePos &lt;- format(timestamp,"%Y-%m-%d")
  
    updatePortf(Portfolio=portfolio,Symbol=symbol,Dates=datePos)
  updateAcct(portfolio,Dates=datePos)   
  updateEndEq(portfolio,Dates=datePos)     
  Posn &lt;- getPosQty(portfolio,Symbol=symbol,Date=datePos)
  equity &lt;- getEndEq(portfolio,datePos) 
  ClosePrice &lt;- getPrice(get(symbol))[datePos]
  #UnitSize &lt;- as.numeric(trunc(equity*0.25/ClosePrice)) 
  
  if (Posn == 0) { 
      osInvestAll &lt;- UnitSize } else
          {osInvestAll &lt;- 0
           }
  
  }
  
  Rule1&lt;-function(price,SMA,...)
  {ifelse(price&gt;SMA,1,-1)}
  add.indicator(strategy=strategyname,name="SMA",
            arguments=list(x=quote(mktdata$Close),n=40),label="SMA40")
  
  add.indicator(strategyname, name="Rule1", arguments=list(price =     quote(mktdata$Close), SMA=quote(mktdata$SMA.SMA40)), label="Rule1Signal")
  
  Rule2&lt;-function(SMA2,SMA5,...)
  {ifelse(SMA5&gt;SMA2,1,-1)}
  add.indicator(strategy=strategyname,name="SMA",
            arguments=list(x=quote(mktdata$Close),n=2),label="SMA2")
  add.indicator(strategy=strategyname,name="SMA",
            arguments=list(x=quote(mktdata$Close),n=5),label="SMA5")
  
  add.indicator(strategyname, name="Rule2",     arguments=list(SMA5=quote(mktdata$SMA.SMA5), SMA2=quote(mktdata$SMA.SMA2)), label="Rule2Signal")
  
  
  
  
  #Daily range less than the 10 day average range, buy next day if todays close was higher (+1) or short if it was lower 
  #HLC &lt;- HLC(DJI)
  Rule3&lt;-function(HLC, n)
  { 
     DJI$TR &lt;- ATR(HLC(DJI),10)[,1]    
      DJI$todays &lt;-DJI$High-DJI$Low
  
  Rule3 &lt;- ifelse(DJI$todays&gt;DJI$TR, ifelse((HLC$Close &gt; lag.xts(HLC$Close)), -1,1), ifelse((HLC$Close &gt;       lag.xts(HLC$Close)), 1, -1))
  
  }
  
      add.indicator(strategyname, name="Rule3", arguments=list(HLC=quote(HLC(mktdata)), n=10), label="Rule3Signal")
  
  
  ##Donchian Channel
  #High
  Rule4 &lt;- function(H,L,Close)
  {ifelse(Close&gt;H,1,0)}
  
  add.indicator(strategy=strategyname,name="DonchianChannel",
            arguments=list(HL=quote(mktdata$Close),n=50),label="DCH")
  
  add.indicator(strategyname, name="Rule4", arguments=list(H=quote(mktdata$high.DCH),L=quote(mktdata$low.DCH),Close=quote(mktdata$Close)), label="Rule4Signal")
  #Low
  Rule6 &lt;- function(H,L,Close)
  {ifelse(Close&lt;L,-1,0)}
  
  add.indicator(strategy=strategyname,name="DonchianChannel",
            arguments=list(HL=quote(mktdata$Close),n=50),label="DCH")
  
  add.indicator(strategyname, name="Rule6", arguments=list(H=quote(mktdata$high.DCH),L=quote(mktdata$low.DCH),Close=quote(mktdata$Close)), label="Rule6Signal")
  
  
  
  #Rule 5
  Rule5&lt;-function(H15,L15)
  {
  X&lt;-(H15+L15)/2
  ifelse(DJI$Close&gt;X,1,-1)}
  
      add.indicator(strategy=strategyname,name="SMA",
            arguments=list(x=quote(mktdata$High),n=15),label="H15")
      add.indicator(strategy=strategyname,name="SMA",
            arguments=list(x=quote(mktdata$Low),n=15),label="L15")
  
      add.indicator(strategyname, name="Rule5", arguments=list(Close=quote(mktdata$Close), H15=quote(mktdata$High),L15=quote(mktdata$Low)), label="Rule5Signal")
  
  
  
  
  RuleSum &lt;- function(R1,R2,R3,R4,R5,R6,...)
  {
  RuleSum &lt;- ( R1 + R2 + R3 + R4 + R5 + R6 )
  }
  add.indicator(strategyname, name="RuleSum",     arguments=list(R1=quote(mktdata$Close.Rule1Signal), R2=quote(mktdata$SMA.SMA5.Rule2Signal),R3=quote(mktdata$todays.Rule3Signal),R4=quote(mktdata$Rule4Signal),R5=quote(mktdata$Close.Rule5Signal),R6=quote(mktdata$Close.Rule6Signal)), label="RuleSum")
  
  
  #Signals
  add.signal(strategyname,name="sigThreshold",
         arguments=list(column="Close.Rule1Signal.RuleSum",relationship="gt",threshold=0,cross=FALSE),
    label="signal.gt.zero")
  
  
   add.signal(strategyname,name="sigThreshold",
    arguments=list(column="Close.Rule1Signal.RuleSum",relationship="lt",threshold=0,cross=FALSE),
    label="signal.lt.zero")
  
  
  
  #Rules
   add.rule(strategyname,name='ruleSignal',
  arguments = list(sigcol="signal.gt.zero", sigval=TRUE,
  replace=FALSE,
  prefer='open',
  orderside='long',
  ordertype='market',
  orderqty=1,
  orderset='ocolong'
    ),
    type='enter',
    label='LE'
   )
  
  
  add.rule(strategyname,name='ruleSignal',
  arguments = list(sigcol="signal.gt.zero", sigval=TRUE,
  replace=FALSE, 
  prefer='close',
  orderside='long',
  ordertype='market',
  orderqty='all',
  orderset='ocolong'
    ),
    type='exit',
    label='LX'
  )
  
  trailingStopPercent &lt;- .20
  
   add.rule(strategyname, name = 'ruleSignal',
   arguments=list(sigcol="signal.gt.zero" , sigval=TRUE,
   replace=FALSE,
   prefer='close',
   orderside='long',
   ordertype='stoptrailing',
   tmult=TRUE,
   threshold=quote(trailingStopPercent),
   orderqty='all',
  orderset='ocolong'
    ),
  type='chain', parent="LE",
  label='StopTrailingLong',
  enabled=TRUE
   )
  
  ###short rules
  add.rule(strategyname,name='ruleSignal',
  arguments = list(sigcol="signal.lt.zero", sigval=TRUE,
  replace=FALSE,
  prefer='open',
  orderside='short',
  ordertype='market',
  orderqty=-1,
  orderset='ocoshort'
  ),
  type='enter',
  label='SE'
  )
  
  
  add.rule(strategyname,name='ruleSignal',
  arguments = list(sigcol="signal.lt.zero", sigval=TRUE,
  replace=FALSE,  
  prefer='close',
  orderside='short',
  ordertype='market',
  orderqty='all',
  orderset='ocoshort'
    ),
    type='exit',
    label='SX'
  )
  
  trailingStopPercent &lt;- .20
  
  add.rule(strategyname, name = 'ruleSignal',
  arguments=list(sigcol="signal.lt.zero" , sigval=TRUE,
  replace=FALSE,
  prefer='close',
  orderside='long',
  ordertype='stoptrailing',
  tmult=TRUE,
  threshold=quote(trailingStopPercent),
  orderqty='all',
  orderset='ocoshort'
    ),
  type='chain', parent="SE",
  label='StopTrailingShort',
  enabled=TRUE
   )
  
  summary(getStrategy(strategyname))
  
       applyStrategy(strategy=strategyname,portfolios=portfolioname,verbose=TRUE,update.equity = TRUE, showEq = TRUE) #verbose=FALSE not to print
  
  
  updatePortf(strategyname)
  updateAcct(strategyname)
  updateEndEq(strategyname)
  </code></pre>