I found this code which looks interesting, posted by a member and pasted it in but it shows error on the last line ' }expectation' I am clueless about coding, but I thought that I might be lucky if I just pasted it into a new indicator.
Can anyone help?
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Exponential Moving Average. The Exponential Moving Average is an indicator that shows the average value of a security's price over a period of time. When calculating a moving average. The EMACOLORS2 applies more weight to recent prices than the SMA.
/// </summary>
[Description("The Exponential Moving Average is an indicator that shows the average value of a security's price over a period of time. When calculating a moving average. The EMACOLORS2 applies more weight to recent prices than the SMA.")]
public class EMACOLORS2 : Indicator
{
#region Variables
private int period = 14;
private int ema34slope = 0;
private double radToDegrees = 180/Math.PI; // to convert Radians to Degrees for slope calc
private int angle1 = 30;
private int angle2 = 60;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Green, "EMAup"));
Add(new Plot(Color.Maroon, "EMAdown"));
Add(new Plot(Color.Red, "EMAslopedown"));
Add(new Plot(Color.LimeGreen, "EMAslopeup"));
Add(new Plot(Color.Gray, "EMAflat"));
Plots[0].Pen.Width = 2;
Plots[1].Pen.Width = 2;
Plots[2].Pen.Width = 2;
Plots[3].Pen.Width = 2;
Plots[4].Pen.Width = 2;
Plots[0].Pen.DashStyle = DashStyle.Dash;
Plots[1].Pen.DashStyle = DashStyle.Dash;
Plots[2].Pen.DashStyle = DashStyle.Dash;
Plots[3].Pen.DashStyle = DashStyle.Dash;
Plots[4].Pen.DashStyle = DashStyle.Dash;
Overlay = true;
PriceTypeSupported = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(CurrentBar<Period) return;
ema34slope = (int)(radToDegrees*(Math.Atan((EMA(34)[0]-(EMA(34)[1]+EMA(34)[2])/2)/1.5/TickSize)));
if(Rising(EMA(Period)))
{
if(ema34slope>=angle2)
{
EMAslopeup.Set(1,EMA(Period)[1]);
EMAslopeup.Set(EMA(Period)[0]);
}
else
if (ema34slope>=angle1)
{
EMAup.Set(1,EMA(Period)[1]);
EMAup.Set(EMA(Period)[0]);
}
else
{ EMAflat.Set(1,EMA(Period)[1]);
EMAflat.Set(EMA(Period)[0]);
}
}
else
{ if(ema34slope<=-angle2)
{
EMAslopedown.Set(1,EMA(Period)[1]);
EMAslopedown.Set(EMA(Period)[0]);
}
else
if (ema34slope<=-angle1)
{
EMAdown.Set(1,EMA(Period)[1]);
EMAdown.Set(EMA(Period)[0]);
}
else
{ EMAflat.Set(1,EMA(Period)[1]);
EMAflat.Set(EMA(Period)[0]);
}
}
}
Comment