Tick Filter sample

The source for Tick Filter

Tick Filter description

In signal processing, a filter is a device or process that removes some unwanted components or features from a signal. Please find detailed explanation in Wikipedia article.

In trading strategy we may not want to open position if price or some indicator is showing extreme value. Here we review an implementation which filters tick prices at RSI price extremes where RSI is greater than 80 or less than 20.

Our filter design looks this: If RSI is greater than 80 or less than 20 we take no action and move back to our initial state. If RSI is between 20 and 80 then we move forward to next state to check our trade rules and welcome any other input to trigger our trade entry.


And same in C code. Function _rsiFilter() returns true/false according to filter design.


public bool _rsiFilter()
{
    if( _rsi.Current > 80 || _rsi.Current < 20 )
        return true;
    else
        return false;
}
#endregion

Function NewTick returns without any action if filtered. If not filtered, replace else branch with your trade rules.


public override void NewTick(BarData partialBar, TickData tick)
{	
	if( _rsiFilter() )
		return; // take no action
	else
		; //your trading logic here
}

While the example is simple it can be used as base for construction of filters based strategies.