0

我想知道是否有人可以帮助我修改我的止损(止损)规则。如何将其更改为以低于限价的收盘价卖出,而不是低于限价的低位卖出?

> #rules add.rule(strategy.st, name="ruleSignal", 
>          arguments=list(sigcol="buyTrigger", sigval=TRUE, ordertype="market", 
>                         orderside="long", replace=FALSE, prefer="Open", 
>                         osFUN=osDollarATR, tradeSize=tradeSize,
>                         pctATR=pctATR, atrMod="X"), 
>          type="enter", path.dep=TRUE,
>          label="newEntry")
> 
   add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="buyTrigger", 
                        sigval=FALSE, 
                        ordertype="stoplimit", 
                        orderside="long", 
                        replace=FALSE, 
                        orderqty='all',
                        order.price=quote(mktdata$loss.stopLimit[timestamp]),
                        orderset="orders"),
         type="chain",
         parent="newEntry",
         label="takeProfitLong",
         path.dep=TRUE)
4

1 回答 1

0

我下载了源代码并打开了 tar.gz 文件夹来修改 ruleOrderProc.R。

卸载并重新安装包。经过几次尝试,我能够将代码修改为:

if ((orderQty > 0 && orderType != "stoplimit") || 
                    (orderQty < 0 && (orderType == "stoplimit"))) {
                    if ((has.Cl(mktdata) && orderPrice > as.numeric(Cl(mktdataTimestamp)[, 
                      1])) || (!has.Cl(mktdata) && orderPrice > 
                      as.numeric(getPrice(mktdataTimestamp, prefer = prefer)[, 
                        1])))

...

于 2016-02-16T19:35:12.090 回答