Any help would be much appreciated!
Heres an image to show what I mean
And here is my code:
#region Using declarations
/// <summary>
/// 5 sma crosses the 12 sma. Simple Bet both ways
/// </summary>
[Description("5 sma crosses the 12 sma. Simple Bet both ways")]
public class SMA5overSMA12 : Strategy
{
#region Variables
// Wizard generated variables
private int stopLoss = 20; // Default setting for StopLoss
private int betSize = 1; // Default setting for BetSize
private int dema = 25; // Default setting for Dema
private int ema = 60;// Default setting for Ema
// 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;
Add(DEMA(Dema));
Add(EMA(Ema));
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(CrossAbove(DEMA(Dema),EMA(Ema),1));
{
EnterLong(BetSize);
Print (Time[0] + ("Cross Above"));
}
if(CrossBelow(DEMA(Dema), EMA(Ema),1));
{
EnterShort(BetSize);
Print(Time[0] + ("Cross Below"));
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int StopLoss
{
get { return stopLoss; }
set { stopLoss = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int BetSize
{
get { return betSize; }
set { betSize = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Dema
{
get { return dema; }
set { dema = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Ema
{
get { return ema; }
set { ema = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Smooth
{
get { return smooth; }
set { smooth = Math.Max(1, value); }
}
#endregion
}
}
Comment