When I use the following code, I have a problem with the variables. When I try to backtest the strategy the window into which you adjust your variables is all completely blank and I am not able to go any further.
I was working fine until I put in the "private bool traded = false;" I think I have it in the wrong place.
Please give some suggestions.
Thanks
Glen
/// <summary>
/// End of Day Trade
/// </summary>
[Description("End of Day Trade")]
public class EndOfDayTrade : Strategy
{
#region Variables
// Wizard generated variables
private int profitTarget = 44; // Default setting for ProfitTarget
private int stopLoss = 15; // Default setting for StopLoss
// User defined variables (add any user defined variables below)
#endregion
private bool traded = false;
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Add(OpenPrice830(8, 30));
Add(ClosePrice1429(14, 29));
Add(Stochastics(4, 6, 2));
Add(OpenPrice830(8, 30));
Add(ClosePrice1429(14, 29));
Add(Stochastics(4, 6, 2));
SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);
SetStopLoss("", CalculationMode.Ticks, StopLoss, false);
CalculateOnBarClose = true;
if (Bars.FirstBarOfSession && FirstTickOfBar)
traded = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (ToTime(Time[0]) > ToTime(14, 30, 0)
&& OpenPrice830(8, 30).OpenPrice[0] < ClosePrice1429(14, 29).ClosePrice[0]
&& Stochastics(4, 6, 2).D[1] < Stochastics(4, 6, 2).D[0]
&& Open[0] < Close[0]
&& traded == false)
{
EnterLong(DefaultQuantity, "EDT Long");
traded = true;
}
// Condition set 2
if (ToTime(Time[0]) > ToTime(14, 30, 0)
&& OpenPrice830(8, 30).OpenPrice[0] > ClosePrice1429(14, 29).ClosePrice[0]
&& Stochastics(4, 6, 2).D[1] > Stochastics(4, 6, 2).D[0]
&& Open[0] > Close[0]
&& traded == false)
{
EnterShort(DefaultQuantity, "EDT Short");
traded = true;
}
}

Comment