Posted By: vinitrinh
LowPass filter is not the same as Workshop 4a - 04/28/22 02:43
I've seen other posts that shared the formula of the LowPass filter and have tried the workshop 4a script. However, it seems like the formula is not producing the same results as the inbuilt LowPass filter.
Below is the code for recreating the experiment.
Comment the second low pass codes for Trends and MMI to replicate results.
Also attached are the backtest results of using the inbuilt LowPass and that of using Workshop 4a's lowpass.
Do we know the exact formula of the inbuilt lowpass?
Below is the code for recreating the experiment.
Comment the second low pass codes for Trends and MMI to replicate results.
Also attached are the backtest results of using the inbuilt LowPass and that of using Workshop 4a's lowpass.
Do we know the exact formula of the inbuilt lowpass?
Code
var lowpass(vars In,int Period) { var a = 1./(1+Period); vars Out = series(In[0],3); return Out[0] = (a-0.25*a*a)*In[0] + 0.5*a*a*In[1] - (a-0.75*a*a)*In[2] + (2-2*a)*Out[1] - (1-a)*(1-a)*Out[2]; } function run() { EndDate = 20171231; // fixed simulation period Verbose = 2; LookBack = 300; // needed for MMI asset("EUR/USD"); set(LOGFILE,PLOTNOW); // log all trades vars Prices = series(priceClose()); vars Trends = series(LowPass(Prices,300)); vars Trends = series(lowpass(Prices,300)); vars Trends2 = series(lowpass(Prices,300)); Stop = 30*ATR(100); // very distant stop vars MMI_Raws = series(MMI(Prices,300)); vars MMI_Smooths = series(LowPass(MMI_Raws,300)); vars MMI_Smooths = series(lowpass(MMI_Raws,300)); if(falling(MMI_Smooths)) { if(valley(Trends)) enterLong(); else if(peak(Trends)) enterShort(); } string Row = strf( "%02i/%02i/%02i %02i:%02i,%.5f,%.5f,%.5f,%.5f,%.5f,%.5f\n", day(),month(),year()%100,hour(),minute(), priceO(),priceH(),priceL(),priceC(), Trends[0], Trends2[0]); if(is(INITRUN)) file_delete("Data\\export.csv"); // Create header row here // file_append("Data\\export.csv",Row); else file_append("Data\\export.csv",Row); }