I'm a new NinjaTrader user, and I'm trying to create an indicator (the Elder Autoenveloppe).
But the language bothers me as I can't manage to compile my code.
I'm a user of ProrealTime and the line I can't translate to NinjaTrader is the following :
STD[NbBars](2*Max(Abs(High-avg) ,Abs(Low-avg)) / avg)
where
- STD : the "standard deviation" mathematical formula
- NbBars is the number of bars on which to calculate the standard deviation
- Max : a function that returns the greatest of the argument (Exemple : Max(X,Y) returns X if X>Y)
- Abs : the "absolute value" of a parameter : Example : Abs(-5) = 5 or Abs(6) = 6
- avg : it's the value of a exponential moving average.
So, what I want to calculate is just the standard deviation, measured on "NbBars" days, of "the greatest distance between the high and the mean, or the low and mean, divided by the mean".
As I could not retrieve the "max" (which has a different meaning in Ninja Trader) and "abs" functions, I had to re-do everything by hand.
So far, I have :
double myEMA = 0;
double ABS1 = 0;
double ABS2 = 0;
double dif1 = 0;
double dif2 = 0;
double ABS = 0;
double DistanceRatio =0;
myEMA = EMA(Close, EMALength)[0];
dif1 = High[0] - myEMA;
if (dif1 >= 0)
{ ABS1 = (High[0] - myEMA); }
else
{ABS1 = (myEMA - High[0]);}
if (Low[0] - myEMA > 0)
{ABS2 = Low[0] - myEMA;}
else
{ABS2 = myEMA - Low[0];}
if (ABS1 >= ABS2)
{ABS = ABS1;}
else
{ABS = ABS2;}
DistanceRatio = 2* (ABS/myEMA);
ChannelSize=StdDev(DistanceRatio,NbBars)[0];
But it won't compile it .... error CS1502 on the last line (StdDev).
When I look at the doc, I don't understand why my parameters are incorrect.
Can somebody help ?
Second question : is there an equivalent to the metastock "lastValue" function ?
Many thanks in advance !

Comment