Notch Filter & Bandpass Filter

Posted By: Smallz

Notch Filter & Bandpass Filter - 01/16/23 06:09

I played around with ChatGPT and asked it totell me what spectral filters can be used for trading and gave it an example in Lite-C.
Then I asked it for an example for a Nothc Filter and a Bandpass Filter

Here is what I got:
Code
 
// Notch filter
function tradeNF()
{
    var NotchWidth = optimize(10,5,30);
    var Threshold = optimize(0.1,0.05,0.5);
    var DominantFrequency = DominantFrequency(Prices);
    var NotchFrequency = DominantFrequency - NotchWidth;
    vars NotchFilter = series(NotchFilter(Prices,NotchFrequency,NotchWidth));
    vars Signals = series(Fisher(NotchFilter,NORMPERIOD));
    algoSetup();

    if(crossUnder(Signals,-Threshold)) 
        trade(-1);
    else if(crossOver(Signals,Threshold)) 
        trade(1);
}



and

Code
// BandStop filter
function tradeBSF()
{
    var BandStopWidth = optimize(10,5,30);
    var Threshold = optimize(0.1,0.05,0.5);
    var DominantFrequency = DominantFrequency(Prices);
    var StopFrequencyLow = DominantFrequency - BandStopWidth;
    var StopFrequencyHigh = DominantFrequency + BandStopWidth;
    vars BandStopFilter = series(BandStopFilter(Prices,StopFrequencyLow,StopFrequencyHigh));
    vars Signals = series(Fisher(BandStopFilter,NORMPERIOD));
    algoSetup();

    if(crossUnder(Signals,-Threshold)) 
        trade(-1);
    else if(crossOver(Signals,Threshold)) 
        trade(1);
}




"DominantFrequency" is an unknown variable, however
Anybody have fun playing around with this? Not sure about the optimize values, etc...
Posted By: rki

Re: Notch Filter & Bandpass Filter - 04/10/23 18:09

BandStop filter is not a BandPass filter
© 2024 lite-C Forums