Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

bad tick clean for Amibroker (AFL)
pious243
about 11 years ago
Amibroker (AFL)

Rating:
3 / 5 (Votes 2)
Tags:
amibroker

This chart is used to generate clean data for another chart.
Link this chart to another one.
This runs on a 5 second database to trim bad ticks.
Clean data is saved to “~SA_Clean” ATC ticker every pass.
Linked chart must replace OHLCV arrays.
Place the following AFL at the beginning of the linked chart:
SetForeign("~SA_Clean)
Try out your own high resolution data filtering algorithms

Similar Indicators / Formulas

Kavach Of Karna v2
Submitted by hbkwarez almost 10 years ago
Advanced Elliott Waves
Submitted by MarcosEn over 12 years ago
3_6Day GuaiLiLv
Submitted by motorfly over 12 years ago
Williams Alligator System
Submitted by durgesh1712 over 12 years ago
*Level Breakout system*
Submitted by Tinych over 12 years ago
Horizontal Live Priceline Tool
Submitted by northstar over 12 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("5 sec Bad Ticks"); 
FilterType = ParamList("Filter type","None|TEMAOC4|MedianOHLC9]|UnSpike",1);

if(FilterType=="UnSpike" )
{
	CH=C==H; CL=C==L; OH=O==H; OL=O==L;
	MH=Median(H,4); ML=Median(L,4);
	MH[0]=MH[1]=MH[2]=MH[3]=MH[4]; //workaround for bug?
	ML[0]=ML[1]=ML[2]=ML[3]=ML[4]; //workaround for bug?
	H=IIf(CH,MH,H); //trim glitch High close
	C=IIf(CH,MH,C); //trim glitch Close high
	O=IIf(OH,MH,O); //trim glitch Open high
	H=IIf(OH,MH,H); //trim glitch High open
	L=IIf(CL,ML,L); //trim glitch Low close
	C=IIf(CL,ML,C); //trim glitch Close low
	O=IIf(OL,ML,O); //trim glitch Open low
	L=IIf(OL,ML,L); //trim glitch Low open
	H=Min(H,Min(MH*2-L,H)); //trim out of range H
	L=Max(L,Max(ML*2-H,L)); //trim out of range L
	O=Min(H,Max(L,O)); //trim out of range O
	C=Min(H,Max(L,C)); //trim out of range C
}

if(FilterType=="MedianOHLC9" )
{
	H=Median(H,9);
	L=Median(L,9);
	O=Min(H,Max(L,O));
	C=Min(H,Max(L,C));
}

if(FilterType=="TEMAOC4" ){O=H=L=C=TEMA((O+C)/2,4);}

AddToComposite(O ,"~SA_Clean" ,"O",atcFlagEnableInIndicator|atcFlagDeleteValues);
AddToComposite(H ,"~SA_Clean" ,"H",atcFlagEnableInIndicator);
AddToComposite(L ,"~SA_Clean" ,"L",atcFlagEnableInIndicator);
AddToComposite(C ,"~SA_Clean" ,"C",atcFlagEnableInIndicator);
AddToComposite(V ,"~SA_Clean" ,"V",atcFlagEnableInIndicator);

_SECTION_END(); // end of bad tick removal routine


_SECTION_BEGIN("Test Timeframes"); //Explore timeframe functions

Chartframe = ParamList("Chart Type","None|Native|Time bars|Volume bars|$Range bars|%Range bars",0);
Timebar = 60*Param("Time (minutes)",1,1,10,1);
Volumebar = 12*Param("Volume (avg rate)",1,.25,10,.25); //finds a volume with an average bar rate in minutes
Rangebar = Param("$ Range",.1,.01,10,.01);
RangebarP = Param("% Range",.1,.01,2,.01)/100;

if(Chartframe=="Time bars")
{
	Plot(Timebar/60 ,"Bar Minutes",colorBlue,styleNoLabel|styleNoLine|styleOwnScale); //just for the number
	TimeFrameMode(0);
	TimeFrameSet(Timebar ); //force n*5 second bars now
}

if(Chartframe=="Volume bars")
{
	// first total all the volume for the last 4680 bars between 9:30 and 4:00 only to get a volume per 5 sec bar
	Totalv=0; totalbars=0;
	bartimes = TimeNum(); //time of day to gather volume
	for(i=BarCount-1;totalbars<4680;i--)
	{
		if(bartimes[i]>=93000 AND bartimes[i]<160000){Totalv += V[i]; totalbars++;}
	}
	avevol = Volumebar*Totalv/4860;
	ex = int(log10(avevol))-1; //2 significant digits to keep
	barvol = ((10^ex)*(round((avevol)/(10^ex)))); //truncate significance to keep from dithering
	Plot(barvol ,"Bar Vol",colorBlue,styleNoLabel|styleNoLine|styleOwnScale); //just for the number
	TimeFrameMode(2);
	TimeFrameSet(barvol);
}

if(Chartframe=="$Range bars") //this does not work right, Bug???
{
	Plot(Rangebar ,"Bar range",colorBlue,styleNoLabel|styleNoLine|styleOwnScale); //just for the number
	TimeFrameMode(3);
	TimeFrameSet(Rangebar );
} 

if(Chartframe=="%Range bars") //this does not work right either, Bug???
{
	// first total all the prices for the last 4680 bars between 9:30 and 4:00 only to get an average price
	Totalp=0; totalbars=0;
	bartimes = TimeNum(); //time of day to gather volume
	for(i=BarCount-1;totalbars<4680;i--)
	{
		if(bartimes[i]>=93000 AND bartimes[i]<160000){Totalp += C[i]; totalbars++;}
	}
	range = RangebarP*Totalp/4860;
	ex = int(log10(range))-1; //2 significant digits to keep
	barP = ((10^ex)*(round((range)/(10^ex)))); //truncate significance to keep from dithering
	Plot(barP ,"Bar range",colorBlue,styleNoLabel|styleNoLine|styleOwnScale); //just for the number
	TimeFrameMode(3);
	TimeFrameSet(barP );
} 

if(Chartframe!="None") //use none for high speed
{
	Plot(C ,"Price",colorBlue,styleBar);
	// quick and dirty trading day start and end markers
	Plot( TimeNum()>=160000 AND Ref(TimeNum(),-1)<160000 , "", colorRed,styleOwnScale|styleNoLabel|styleDashed|styleHistogram);
	Plot( TimeNum()>=93000 AND Ref(TimeNum(),-1)<93000, "", colorGreen,styleOwnScale|styleNoLabel|styleDashed|styleHistogram);
}
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.

Back