I hope someone can help with my two questions.
First off (i guess i'll be the millionth person to ask) - I have tried to create an indicator for market analyser. However was unable to write the script as a indicator instead had to use a strategy. Is it possible to change a strategy to an indciator or copy and paste the script into the indicator editor.
Secondly,
I put together the below script. i am, however, coming up with an error message. it says line 39, column 13 "only assignment, call, increment, decrement and new object expressions can be used. Can someone help? I have highlighted the bit read.
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Sector asset Allocation
/// </summary>
[Description("Sector asset Allocation")]
public class SectorTAA : Strategy
{
#region Variables
// Wizard generated variables
private int price = 1; // Default setting for Price
private int mA20 = 1; // Default setting for MA20
private int mA50 = 1; // Default setting for MA50
private int mA200 = 1; // Default setting for MA200
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
(CalculateOnBarClose = True);
}
/// <summary>;
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] > SMA(200)[0]&&(SMA(20)[0] > SMA(50)[0]))
{
Alert("MyAlert0", Priority.High, "Buy", "", 0, Color.White, Color.Black);
Log("Buy", LogLevel.Information);
}
else if (Close[0] > SMA(200)[0]&&(SMA(20)[0] < SMA(50)[0]))
{
Alert("MyAlert1", Priority.High, "Reduce", "", 0, Color.White, Color.Black);
Log("Reduce", LogLevel.Information);
}
else if (Close[0] < SMA(200)[0]&&SMA(20)[0] < SMA(50)[0])
{
Alert("MyAlert2", Priority.High, "Sell", "", 0, Color.White, Color.Black);
Log("Sell", LogLevel.Information);
}
else if (Close[0] < SMA(200)[0]&&SMA(20)[0] > SMA(50)[0])
{
Alert("MyAlert3", Priority.High, "Add", "", 0, Color.White, Color.Black);
Log("Add", LogLevel.Information);
}
else if (Close[0] > SMA(200)[0]&&SMA(20)[0] > SMA(50)[0])
{
Alert("MyAlert4", Priority.High, "Buy", "", 0, Color.White, Color.Black);
Log("Buy", LogLevel.Information);
}
}
#region Properties
[Description("Price of Instrument")]
[GridCategory("Parameters")]
public int Price
{
get { return price; }
set { price = Math.Max(1, value); }
}
[Description("MA20 of Instrument")]
[GridCategory("Parameters")]
public int MA20
{
get { return mA20; }
set { mA20 = Math.Max(1, value); }
}
[Description("MA50 of Instrument")]
[GridCategory("Parameters")]
public int MA50
{
get { return mA50; }
set { mA50 = Math.Max(1, value); }
}
[Description("MA200 of Instrument")]
[GridCategory("Parameters")]
public int MA200
{
get { return mA200; }
set { mA200 = Math.Max(1, value); }
}
#endregion
}
}

Comment