[R-SIG-Finance] Help required in getting SMA triggered entry with quantstrat add.rule

Brian G. Peterson brian at braverock.com
Mon Aug 1 21:08:39 CEST 2016


<on-list>

Instant execution can't happen.

If you insist, pass 

allowMagicalThinking=TRUE 

in the call to applyStrategy.

If you want to execute at your signal price, the 'right answer' is to
use higher frequency data, and enter an order after you get the signal.
If you insist on believing that you can execute at the signal price, add
a column for the signal price, e.g. "magic_signal_price" when you add
your indicators, and pass

prefer="magical_signal_price" in the arguments list for your entry rule.

This is *not* a realistic "proof of concept", where your goal should be
to focus on *disproving* your assumptions, not insisting on unrealistic
execution assumptions.  

Yes, you can do it, and quantstrat will let you.  That doesn't make it a
good idea.  

We've tried to make it hard to make most of the common mistakes, and try
to make more realistic assumptions the default (and have documented them
in the manual).

Brian 

On Mon, 2016-08-01 at 19:31 +0400, golam sakline wrote:
> Hi Brian,
> 
> 
> Really appreciate you responding to my query. While I understand what
> you are saying, I I am just using the SMA indicator to assess whether
> it is possible to execute On Signal date trade to build our proof of
> concept in R Quantstrat. Our signal generator is using a
> predictive pricing mechanism and when the real market price becomes
> equal to/crosses the predicted price, a trade is executed at market
> within some parameters of slippage.  From your reply should I presume
> that a day late execution from signal date is deliberate and you have
> a mechanism of making it on signal date execution?
> 
> 
> thanks
> 
> 
> Golam
> 
> On Mon, Aug 1, 2016 at 2:22 PM, Brian G. Peterson
> <brian at braverock.com> wrote:
>         On 08/01/2016 05:07 AM, golam sakline wrote:
>                 In Quantstrat, is it possible to use add.rule that can
>                 pick the crossover
>                 between SMA and the price as entry rather than the bar
>                 close price? Is
>                 there a way I can add buy-stop and sell-stop order
>                 types using limits that
>                 look into the SMA figures.
>                 
>                 Also why does it seem like that the trade registration
>                 date is one day
>                 late? How can we fix this to register as per the day
>                 of the signal?-- See
>                 the mktdata and getTxns output.
>         
>         Real markets are not instant. It is physically impossible to
>         observe a signal and act on it at the same instant.  You must
>         observe your signal, do some calculation, place an order, the
>         market must receive your order, and the market must match your
>         order.
>         
>         If you want action at higher frequencies, use higher frequency
>         data.
>         
>         If you insist on proceeding with unrealistic expectations,
>         pass
>         
>         allowMagicalThinking=TRUE
>



More information about the R-SIG-Finance mailing list