It must unconditional open positions on all instruments at 02:00 and close all at 22:00 every day.
I backtest it on 04.06.2010 - 20.08.2010 an get only 1 deal.
My history is OK - It clear on chart screenshot.
Help me, please, to let this strategy work correct.
namespace NinjaTrader.Strategy
{
/// <summary>
/// GBPJPY only
/// </summary>
[Description("USDJPY only")]
public class sMultuCurrencySimple : Strategy
{
#region Variables
#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()
{
Add("$AUDJPY", BarsPeriod.Id, BarsPeriods[0].Value);
Add("$CHFJPY", BarsPeriod.Id, BarsPeriods[0].Value);
Add("$EURJPY", BarsPeriod.Id, BarsPeriods[0].Value);
Add("$GBPJPY", BarsPeriod.Id, BarsPeriods[0].Value);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// ------------------ Open positions -----------------------------------------------------------
//
if (BarsInProgress == 1 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
if (BarsInProgress == 2 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
if (BarsInProgress == 3 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
if (BarsInProgress == 4 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
if ( Time[0].Hour == 2 ) EnterLong(DefaultQuantity, "");
// ---------------------------------------------------------------------------------------------
// ------------------------------------ Close positions---------------------
//
if ( Time[0].Hour == 22)
{
ExitLong( "", ""); ExitShort( "", "");
ExitLong(1, "", ""); ExitShort(1, DefaultQuantity, "", "");
ExitLong(2, "", ""); ExitShort(2, DefaultQuantity, "", "");
ExitLong(3, "", ""); ExitShort(3, DefaultQuantity, "", "");
ExitLong(4, "", ""); ExitShort(4, DefaultQuantity, "", "");
}
// --------------------------------------------------------------------------
}
#region Properties
#endregion
}
}

Comment