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" );

Quote:


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

Then you could remove negative prices via method(s) described in following knowledgebase article.
http://www.amibroker.com/kb/2015/01/13/how-to-delete-quotes/


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));

or

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.

3 Likes

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 https://forum.amibroker.com/t/scan-and-delete-bad-quotes/12274/4

function FilteredArray( filter_var, array ) {	
	/// Return value if set Filter is true within data set 
	/// else return value of previous true Filter
	/// @link https://tinyurl.com/yy3hnnfv
	/// by fxshrat@gmail.com
	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


56

6 Likes