[R-SIG-Finance] Custom indicator for Quantstrat (Fractals by Bill Williams)

Brian G. Peterson brian at braverock.com
Fri Jul 3 03:38:48 CEST 2015


On 07/02/2015 06:44 PM, Dane Edwards wrote:
> Thanks Ilya, does the indicator function get called for every row (like esignal, ninjatrader)  in the xts when the apply strategy function is called? or is the indicator function called once?
> i'm thinking now that the indicator column is calculated before applystrategy is ran, is this correct?


This is covered in the documentation.

You are certainly welcome to add a column or columns to your data before 
calling applyStrategy, but you don't need to do that.

You indicator and signal functions are presumed to be path-independent. 
  They should return an xts time series object of the same length as the 
input data.

It is most efficient to write vectorized indicators or signals, but you 
may write a loop if you like, it will just be slower.

Regards,

Brian

>> From: Ikipnis at grahamcapital.com
>> To: daneedwards1 at hotmail.com; r-sig-finance at r-project.org
>> Subject: RE: [R-SIG-Finance] Custom indicator for Quantstrat (Fractals by Bill	Williams)
>> Date: Thu, 2 Jul 2015 12:42:43 +0000
>>
>> Indicators are just functions like any other R function. EG the quantstrat demos use a lot of the TTR functions, but those TTR are functions are just R functions themselves.
>>
>> -----Original Message-----
>> From: R-SIG-Finance [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of Dane Edwards
>> Sent: Thursday, July 02, 2015 8:25 AM
>> To: r-sig-finance at r-project.org
>> Subject: [R-SIG-Finance] Custom indicator for Quantstrat (Fractals by Bill Williams)
>>
>> Hi, how do i create a custom indicator for quantmod / quantstrat. I'm trying to create a Fractal indicator (Bill Williams), the indicator needs to look back 5 days to calculate if a fractal has happened.
>> http://www.winnersedgetrading.com/how-to-trade-the-fractal-indicator/
>> This is in MQL language
>>   //----Fractals up      FractalFound=false;      dCurrent=High[i];      if(dCurrent>High[i+1] && dCurrent>High[i+2] && dCurrent>High[i-1] && dCurrent>High[i-2])        {         FractalFound=true;        }//i is the current day
>>
>> I'm not sure how the indicators work in quantstrat, in most backtesting software it loops through each day and calculates the indicator (for each day you then look back 5 days), does quanstrat do the same or do i need to write my own looping function in the indicator?
>> Thanks!!



More information about the R-SIG-Finance mailing list