[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: TEMA



PureBytes Links

Trading Reference Links


To avoid searching ...

//	*********************************************** 
//
//	An all purpose routine to find the price 
//		necessary to move an indicator to a GOAL.
//
//	This should work for virtually any indicator,
//		built in or otherwise.  It's demonstrated 
//		here using RSI & BBand's ...
//
//	Note:	It will appear to use future quotes
//				because of the down shifting of the
//				price array, but obviously it can't
//				"know" tomorrows price.  There's 
//				probably a way to rectify this but 
//				I was more concerned with the rest 
//				of the process.
//
//	The maximum iterations have arbitrarily been 
//		set to 200 which is undoubtedly overkill 
//		as I've yet to see anything take 200 even
//		when tolerance was set to 0 on datastreams 
//		with very high prices.
//
//	For real usage the saving of i in j and the
//		accuracy calculation can be tossed as they 
//		were only put in for demonstration purposes 
//
//	***********************************************
//
//	This Routine requires the following things
//
//	P0		= A price array or synthetic
//
//	Goal	= The goal value of the indicator
//
//	Acc		= An accuracy level for the calculations
//
//			  Set this to the order of magnitude 
//			  that you want.  For example if you want 
//			  accuracy in calculated price to within 
//			  0.01 then set it 0.01.  It can even 
//			  be set to 0 which will force AB to 
//			  calculate until it can't find any 
//			  further improvements (Usually between
//			  150-170 iterations) but this is semi
//			  useless as improvements relative to 
//			  price granularity have long since 
//			  been gone by.
//
//			  The lower you set it the longer it 
//			  will take but it's pretty quick 
//			  (Usually between 15-30 iterations) 
//			  unless you set it at 0.
//					
//	***********************************************
//
//	Note:	Some goals are virtually unattainable on
//			the next bar, especially on the downside
//			as they would require a negative price
//			which is what this routine will show if
//			that is what is required.
//
//	***********************************************

P0   = C;

Acc  = 0.0001;

LVBI = LastValue(BarIndex());
Mult = 1;

//	***********************************************
//	Shift Price up by n orders of magnitude to make 
//		it >= 1.  This is useful to increase 
//		accuracy on very low priced datastreams 
//		such as the JY.
//	***********************************************
for (i = 0; i < 10; i++)
{ 
	if (P0[LVBI] >= 1) 
		i = 99; 
	else 
		Mult = Mult * 10; 
} 
// ***********************************************

P1   = Ref(P0, 1) * Mult;
UpDn = 100 * P1[LVBI];

for (i = 0; i < 200; i++)
{

//	An example for finding price associated with the next bars 
BBandTop
//
//
	**************************************************************
***************
//	Put whatever indicator you want to goal seek here based on P1
//
	**************************************************************
***************
	Calc = P1;
//
	**************************************************************
***************
//	Put whatever you want for the goal here ...
//
//	The reason for putting it in the loop is because sometimes 
the goal is price 
//		oriented and will need to be recalculated on each 
iteration.
//
	**************************************************************
***************
	Goal = LastValue(BBandBot(P1, 14, 2));
//
	**************************************************************
***************



//	An example for finding price associated with the next bars 
RSI value of 65
//
//
	**************************************************************
***************
//	Put whatever indicator you want to goal seek here based on P1
//
	**************************************************************
***************
//	Calc = RSIa(P1, 14);
//
	**************************************************************
***************
//	Put whatever you want for the goal here ...
//
//	The reason for putting it in the loop is because sometimes 
the goal is price 
//		oriented and will need to be recalculated on each 
iteration.
//
	**************************************************************
***************
//	Goal = 65;
//
	**************************************************************
***************

	if (Calc[LVBI] < Goal)
		P1[LVBI] = P1[LVBI] + UpDn;
	else
		P1[LVBI] = P1[LVBI] - UpDn;
	UpDn = UpDn / 2;
	if (UpDn <= Acc)
	{
		j = i;
		i = 99999;
	}
}

Accuracy = 100 * (abs(Goal - Calc) / Goal);

Filter = BarIndex() == LVBI;

AddColumn(Mult,					
	"Multiplier",   1.0);
AddColumn(Calc[LVBI - 1] / Mult,	"Curr Ind Val", 1.9);
AddColumn(Goal / Mult,				"Goal Ind Val", 1.9);
AddColumn(Calc[LVBI] / Mult,		"Calc Ind Val", 1.9);
AddColumn(j,						
	"Iterations",   1.0);
AddColumn(Accuracy,   				"Accuray (%)",  1.9);
AddColumn(Ref(P1, -1) / Mult,		"Todays Price", 1.9);
AddColumn(P1 / Mult,					"Goal 
Price",   1.9);

> -----Original Message-----
> From: vichooo_1999 [mailto:vichooo_1999@x...] 
> Sent: Saturday, March 26, 2005 5:15 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: TEMA
> 
> 
> 
> Hi Thomas
> 
> It seems that TEMA MACD crossover gives buy signal earlier than 
MACD 
> crossover so I am also interested in coding to forecast the exact 
> cross over point . The code you have given i am unable to get the 
> desired results. 
> For Eg
> 
> For ^NDx 100
> TEMA MACD is -11.4912
> EMA(TEMA macd,9) is -8.14532
> Where TEMA MACD is the difference between TEMA(c,12) and TEMA(c,26)
> 
> I would like to know the code for determining at what closing the 
> TEMA MACD will be crossing over Ema(TEMA MACD,9)
> 
> thanks in advance
> 
> 
> 
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Thomas Zmuck" <tzg@xxxx> wrote:
> > Hi,
> > 
> > probably this is what you search, however on your formula you 
have 
> not added
> > the ema 9 or maybe tema 9
> > 
> > anyway here is the code:
> > 
> > Samevalue = TEMA(C,12)-TEMA(C,26)==EMA(TEMA(C,12)-TEMA(C,26),9);
> > 
> > Value2 = abs(TEMA(C,12)-TEMA(C,26)/EMA(TEMA(C,12)-TEMA(C,26),9));
> > 
> > Filter = samevalue OR Value2 < 1;
> > AddColumn(C,"Close");
> > AddColumn(Samevalue,"Same Value",1);
> > AddColumn(Value2,"Almost Same Value");
> > 
> > You can explore it in automatic analysis.
> > 
> > Regards
> > 
> > Thomas Zmuck
> > www.tradingbasis.com
> > 
> > 
> >  
> > 
> > -----Original Message-----
> > From: fz_iqbal [mailto:stockslover@x...] 
> > Sent: Saturday, March 26, 2005 4:34 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Re: TEMA
> > 
> > 
> > 
> > Dear Thomas
> > 
> > Thanks for your reply. I am looking for the statistical
> > formula for TEMA macd crossover (just like forecasting
> > at what price macd crossver will take place)
> > 
> > To make it more clear:
> > I wan t to know at what price
> > 
> > TEMA(c,12)-Tema(c,26)=Ema((tema(c,12)-Tema(c,26),9)
> > 
> > I hope you can help me in this matter.
> > 
> > Thanks
> > 
> > Fazal,
> > 
> > 
> > -- In amibroker@xxxxxxxxxxxxxxx, "Thomas Zmuck" <tzg@xxxx> wrote:
> > > Hello Fazal,
> > > 
> > > i believe you get better help when you define your question 
more 
> > precise.
> > > What exactly do you mean with TEMA crossover or TEMA Macd ?
> > > 
> > > As you wrote that you can code it by yourself i am not sure 
what 
> you 
> > mean.
> > > 
> > > As you know, a simple crossover can be coded by: cross(c,tema
> (c,3); 
> > for
> > > example.
> > > 
> > > Regards
> > > 
> > >  
> > > 
> > > Thomas Zmuck
> > > www.tradingbasis.com
> > > 
> > > 
> > >  
> > > 
> > > -----Original Message-----
> > > From: fz_iqbal [mailto:stockslover@x...] 
> > > Sent: Saturday, March 26, 2005 2:19 PM
> > > To: amibroker@xxxxxxxxxxxxxxx
> > > Subject: [amibroker] Re: TEMA
> > > 
> > > 
> > > 
> > > Hi,
> > > 
> > > The problem I am asking is not a ami problem, i know as i can 
> > compute 
> > > TEMA but it is more of a statistical question. I am not asking 
> for 
> > > coding help as I can code it myself but I need help in 
> understanding 
> > > how to calculate TEMA crossover manually.
> > > 
> > > I am sorry to have written it that way as I know it is up to 
the 
> > guys 
> > > here to answer or support a question, but the comments were 
more 
> of 
> > a 
> > > frustration. sorry for  my comments.
> > > 
> > > I sincerely hope somebody comes to my help.
> > > 
> > > Fazal
> > > --- In amibroker@xxxxxxxxxxxxxxx, "klal25" <klal25@xxxx> wrote:
> > > > 
> > > > Fazal,
> > > > 
> > > > If Amibroker has a problem, perhaps contacting the official 
> > support
> > > > channel might be a better idea.  If what you're after is a 
> > solution 
> > > to
> > > > a coding problem, then you are simply dependent upon the 
> > willingness
> > > > of anybody here to help.  I don't think the group is obliged 
to 
> > > solve
> > > > every coding problem!
> > > > 
> > > > Lal
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "fz_iqbal" 
<stockslover@xxxx> 
> > > wrote:
> > > > > 
> > > > > Hi,
> > > > > 
> > > > > I asked question in this forum expecting support for ami, 
but 
> I 
> > am 
> > > > > really dissapointed with the lack of response leave aside 
> > solution 
> > > to 
> > > > > my problem.
> > > > > 
> > > > > Thanks guys
> > > > > 
> > > > > Fazal
> > > > > 
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "fz_iqbal" 
> <stockslover@xxxx> 
> > > wrote:
> > > > > > 
> > > > > > Hi Thomas,
> > > > > > 
> > > > > > Can u please please advise how to manually forecast tema 
> macd 
> > > > > > crossover so that I can code the crossover point. 
> > > > > > 
> > > > > > Fazal
> > > > > > 
> > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "fz_iqbal" 
> <stockslover@xxxx
> > > 
> > > > > wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > Hi,
> > > > > > > 
> > > > > > > I am repeating my question reg. forecasting Tema Macd 
> > > crossover 
> > > > > > point 
> > > > > > > with respect to price. Pls help.
> > > > > > > 
> > > > > > > Fazal
> > > > > > > 
> > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "fz_iqbal" 
> <stockslover@xx
> > ..
> > > > 
> > > > > > wrote:
> > > > > > > > 
> > > > > > > > 
> > > > > > > > Hi Thomas,
> > > > > > > > 
> > > > > > > > Thanks for your reply.
> > > > > > > > 
> > > > > > > > I am trying to write a logic to arriving at the point 
> at 
> > > which a 
> > > > > > > scrip 
> > > > > > > > becomes a tema buy/sell so would like to know how 
TEMA 
> can 
> > > be 
> > > > > > > > calculated manually. Can u please explain how it can 
be 
> > done 
> > > > > > > manually 
> > > > > > > > to code or code it for me as it want to identify the 
> entry 
> > > point 
> > > > > > for 
> > > > > > > > buy or sell, the point obviously i mean is the price. 
> > Thanks 
> > > in 
> > > > > > > > advance.
> > > > > > > > 
> > > > > > > > Fazal
> > > > > > > > 
> > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Thomas Zmuck" 
> <tzg@xxxx
> > > 
> > > > > wrote:
> > > > > > > > > Hi fazal,
> > > > > > > > > 
> > > > > > > > > Check out the amibroker help: 
> > > > > > > > > 
> > > > > > > > > //TEMA can be implemented via EMA:
> > > > > > > > > 
> > > > > > > > > Len=10;
> > > > > > > > > MyTEMA = 3 * EMA(Close,len) - 3 * EMA(EMA
(Close,len),
> > Len) 
> > > +
> > > > > > > > > EMA(EMA(EMA(Close,len),len),len);
> > > > > > > > > 
> > > > > > > > > Plot(MyTEMA,"MyTEMA",colorBlue);
> > > > > > > > > 
> > > > > > > > > // for comparison only
> > > > > > > > > Plot( TEMA( Close, Len ), "Built-in TEMA", 
colorRed );
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > Regards
> > > > > > > > > 
> > > > > > > > >  
> > > > > > > > > 
> > > > > > > > > Thomas Zmuck
> > > > > > > > > www.tradingbasis.com
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > >  
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: fz_iqbal [mailto:stockslover@x...] 
> > > > > > > > > Sent: Monday, March 14, 2005 7:50 AM
> > > > > > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > > > > > Subject: [amibroker] TEMA
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > HI friends,
> > > > > > > > > 
> > > > > > > > > I have been experimenting TEMA buying or sellign 
> point 
> > > with 
> > > > > > > > Metastock 
> > > > > > > > > for sometime but have not been able to identify it. 
I 
> > see 
> > > > > > > amibroker 
> > > > > > > > as 
> > > > > > > > > a more versatile software so may be it will be able 
> to 
> > > > > identify 
> > > > > > > it. 
> > > > > > > > > can any body explain the following
> > > > > > > > > 
> > > > > > > > > whats TEMA ? is it EMA  OF EMA OF EMA ? 
> > > > > > > > > 
> > > > > > > > > becuase if I calculate manually ema of ema of ema
> (c,12) 
> > i 
> > > dont 
> > > > > > get 
> > > > > > > > the 
> > > > > > > > > value of TEMA(c,12) as per amibroker.
> > > > > > > > > 
> > > > > > > > > can anybody explain ?
> > > > > > > > > 
> > > > > > > > > Fazal
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > Please note that this group is for discussion 
between 
> > > users 
> > > > > > only.
> > > > > > > > > 
> > > > > > > > > To get support from AmiBroker please send an e-mail 
> > > directly 
> > > > > to 
> > > > > > > > > SUPPORT {at} amibroker.com
> > > > > > > > > 
> > > > > > > > > For other support material please check also:
> > > > > > > > > http://www.amibroker.com/support.html
> > > > > > > > > 
> > > > > > > > >  
> > > > > > > > > Yahoo! Groups Links
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Please note that this group is for discussion between users 
only.
> > > 
> > > To get support from AmiBroker please send an e-mail directly to 
> > > SUPPORT {at} amibroker.com
> > > 
> > > For other support material please check also:
> > > http://www.amibroker.com/support.html
> > > 
> > >  
> > > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> > 
> > Please note that this group is for discussion between users only.
> > 
> > To get support from AmiBroker please send an e-mail directly to 
> > SUPPORT {at} amibroker.com
> > 
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > 
> >  
> > Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
>  
> Yahoo! Groups Links





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/