Scan and delete bad quotes

i have noticed that IB gives bad ticks @ 5 pm EST. when i run explore, i see this on multiple instances. how can i scan and delete these quotes

Filter = Low<=.05;
AddColumn( C, "Close" );
AddColumn( l, "Low" );


You could create copy of IB symbol via AddToComposite and in addition you may mark it as being used "local" only.

Then you could remove negative prices via method(s) described in following knowledgebase article.

Or if you do not want to go that hassle of deletion every day you could filter negative prices (at top of code).

O = IIf(C > 0, O, Ref(O,-1));
H = IIf(C > 0, H, Ref(H,-1));
L = IIf(C > 0, L, Ref(L,-1));
C = IIf(C > 0, C, Ref(C,-1));


O = IIf(C > 0, O, Null);
H = IIf(C > 0, H, Null);
L = IIf(C > 0, L, Null);
C = IIf(C > 0, C, Null);

Or just Filter them in Exploration via Filter variable if all you do is exploration

Filter = C > 0;

Or another way without any deletion/coding is setting different session times in File - DataBase settings - Intraday settings - Trading hours (As aside... a symbol can have separate session times if it is part of group -> per group intraday sessions -> see manual).

Or use different data vendor.


The solution you proposed is brilliant as i use IB and sometimes the 5 PM ticks are bad. i will not trade that window but it sqews the indicators.
however i noticed that it works only if there is 1 bad tick. If there are 2 bad ticks in a row, it does not work.
so i have used the code in repeat to deal with it.

///filter out bad ticks ///////////////////////
O = IIf(O > 0, O, Ref(O,-1));
H = IIf(H > 0, H, Ref(H,-1));
L = IIf(L > 0, L, Ref(L,-1));
C = IIf(C > 0, C, Ref(C,-1));

O = IIf(O > 0, O, Ref(O,-1));
H = IIf(H > 0, H, Ref(H,-1));
L = IIf(L > 0, L, Ref(L,-1));
C = IIf(C > 0, C, Ref(C,-1));

dunno if there is a way to check for the last time it was >0

Yes, there is a better way to filter multiple spikes (in this case down spikes).
Does not matter where those spikes are located and does not matter how many of them there are.

/// Filter multiple down spike in data set
/// @link

function FilteredArray( filter_var, array ) {	
	/// Return value if set Filter is true within data set 
	/// else return value of previous true Filter
	/// @link
	/// by
	local comp_array, exp_array, val_when;
	comp_array = SparseCompress(filter_var, array);
	exp_array = SparseExpand(filter_var, comp_array);
	val_when = ValueWhen(filter_var, exp_array);
	result = IIf(filter_var, array, val_when);
	return result;

threshold = 0;
// consider only those prices being ABOVE of set threshold value
spike_filter = L > threshold;

filtered_C = FilteredArray(spike_filter, C);
//Plot( filtered_C, "filtered_C", colorRed );

O = IIf(spike_filter, O, filtered_C);
H = IIf(spike_filter, H, filtered_C);
L = IIf(spike_filter, L, filtered_C);
C = IIf(spike_filter, C, filtered_C);

Plot( C, "Price", colorDefault, styleCandle );

// RestorePriceArrays(); // restore original data set