PDA

View Full Version : SampleMACrossOver not working


cbaer
07-05-2010, 05:49 PM
Hi,

The SampleMACrossOver Strategy is not working
on my NT7.18 Beta as you can see in the attachment.
The code is below.
What can I do?

#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.Strategy;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Simple moving average cross over strategy.
/// </summary>
[Description("Simple moving average cross over strategy.")]
public class SampleMACrossOver : Strategy
{
#region Variables
private int fast = 10;
private int slow = 25;
#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()
{
SMA(Fast).Plots[0].Pen.Color = Color.Orange;
SMA(Slow).Plots[0].Pen.Color = Color.Green;

Add(SMA(Fast));
Add(SMA(Slow));

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick).
/// </summary>
protected override void OnBarUpdate()
{
if (CrossAbove(SMA(Fast), SMA(Slow), 1))
EnterLong();
else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
EnterShort();
}

#region Properties
/// <summary>
/// </summary>
[Description("Period for fast MA")]
[GridCategory("Parameters")]
public int Fast
{
get { return fast; }
set { fast = Math.Max(1, value); }
}

/// <summary>
/// </summary>
[Description("Period for slow MA")]
[GridCategory("Parameters")]
public int Slow
{
get { return slow; }
set { slow = Math.Max(1, value); }
}
#endregion
}
}

NinjaTrader_Jason
07-06-2010, 04:47 AM
Hello cbaer,

You will need to set 'Enabled' to True for the strategy to start working. The screenshot displays this is not the case on your end, since it reflects a (D). You can set 'Enabled' in the strategy parameters window that appears when you inititate a strategy.

Let me know if this will not work for you.

cbaer
07-07-2010, 06:18 AM
Hello Jason,

This problem is resolved. Thanks!

cbaer