I implmented this strategy before. It was working fine but it is giving me the following failure now(do not compile). That is very strange. Because DayOfWeek seems to exist in System names space. What is the reason?
#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>
/// Weekend Effect:The weekend effect describes the tendency of stock prices to decrease on Mondays, meaning that closing prices on Monday are lower than closing prices on the previous Friday. For some unknown reason, returns on Mondays have been consistently lower than every other day of the week. In fact, Monday is the only weekday with a negative average rate of return. http://www.investopedia.com/articles...ent-market.asp
/// </summary>
[Description("Weekend Effect:The weekend effect describes the tendency of stock prices to decrease on Mondays, meaning that closing prices on Monday are lower than closing prices on the previous Friday. For some unknown reason, returns on Mondays have been consistently lower than every other day of the week. In fact, Monday is the only weekday with a negative average rate of return. http://www.investopedia.com/articles/stocks/08/market-anomaly-efficient-market.asp")]
public class WeekendEffectStrategy : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// 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()
{
// If its Monday...do not trade
if (Time[0].DayOfWeek == DayOfWeek.Monday && Close[0]<Close[1])
{
DrawDot("Stop" + CurrentBar, 0, High[0], Color.Red);
Print("-");
}
if (Time[0].DayOfWeek == DayOfWeek.Monday && Close[0]>Close[1])
{
DrawDot("Stop" + CurrentBar, 0, Low[0], Color.Green);
Print("+");
}
if (Time[0].DayOfWeek == DayOfWeek.Monday && Close[0]==Close[1])
{
DrawDot("Stop" + CurrentBar, 0, Low[0], Color.Black);
Print("0");
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}
Comment