|How to compare ema with ema previous bar
|Page 1 of 1|
|Author:||maxpi [ Thu Feb 07, 2008 4:00 am ]|
|Post subject:||How to compare ema with ema previous bar|
What code would I use to compare the EMA of the current bar with EMA of the previous bar?
ema1 >ema1 ??
|Author:||Dr. Anton Fokin [ Thu Feb 07, 2008 2:00 pm ]|
ema[ema.Count-1] is the last (most current) entry in the ema indicator series (which is a time series of double number)
ema[ema.Count-2] is the previous entry.
if (ema[ema.Count-1] > ema[ema.Count-2])
If you want to write it more elegantly, you can use Indicator.Last and Indicator.Ago
if (ema.Last > ema.Ago(1))
also, you can simply use Ago everywhere since Indicator.Ago(0) is the same as Indicator.Last
if (ema.Ago(0) > ema.Ago(1))
|Page 1 of 1||All times are UTC + 3 hours|
|Powered by phpBB® Forum Software © phpBB Group