I am very new to quantstrat and R. I have been playing with the pair_trade
example and have been wondering how to implement stop losses that are non
indicator based. I would like to implement a stop loss based on the
movement of the spread. I have looked at the macd example for risk stop
losses however when i apply that same syntax to the pair_trade it does not
affect the system at all. Can anyone help?

The Changes i made to the orignal example code are, labeling the entries as
Long or Short. Then adding 2 additional rules as chain and having them use
a threshold multiplier or +/- .05

*My code for the Rules Section of the example*

pairStrat <- add.rule(strategy=pairStrat, name='ruleSignal',
                      arguments=list(sigcol="cross.dn", sigval=TRUE,
                                     orderqty=1e6, ordertype='market',
                                     orderside=NULL,
osFUN='osSpreadMaxPos'),
                      type='enter',
                      label = 'Long')
pairStrat <- add.rule(strategy=pairStrat, name='ruleSignal',
                      arguments=list(sigcol="cross.up", sigval=TRUE,
                                     orderqty=-1e6, ordertype='market',
                                     orderside=NULL,
osFUN='osSpreadMaxPos'),
                      type='enter',
                      label = 'Short')
pairStrat <- add.rule(strategy=pairStrat, name='ruleSignal',
                      arguments=list(sigcol="cross.mid.fb", sigval=TRUE,
                                     orderqty='all', ordertype='market',
                                     orderside=NULL),
                      type='exit')
pairStrat <- add.rule(strategy=pairStrat, name='ruleSignal',
                      arguments=list(sigcol="cross.mid.fa", sigval=TRUE,
                                     orderqty='all', ordertype='market',
                                     orderside=NULL),
                      type='exit')

pairStrat <- add.rule(strategy=pairStrat, name'ruleSignal',
                      arguments=list(sigcol="cross.dn", sigval=TRUE,
                                     orderqty='all', ordertype='stoplimit',
                                     orderside=NULL,
                                     threshold = -.05, tmult=TRUE,
                                     orderset='exit2'),
                      type = 'chain',
                      parent = 'Long',
                      label = 'LongStop')

pairStrat <- add.rule(strategy=pairStrat, name'ruleSignal',
                      arguments=list(sigcol="cross.dn", sigval=TRUE,
                                     orderqty='all', ordertype='stoplimit',
                                     orderside=NULL,
                                     threshold = .05, tmult=TRUE,
                                     orderset='exit2'),
                      type = 'chain',
                      parent = 'Short',
                      label = 'ShortStop')



Thanks

Derek

        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to