Compiling shown strategy is OK.
[Description("LW Momentum Pivot ws")]
public class LWMPws : Strategy
{
#region Variables
//periods for ATR_big
private int aTR_big_per = 14;
private double EntryATR;
#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()
{
ATR(ATR_big_per).Plots[0].Pen.Color = Color.Blue;
Add(ATR(ATR_big_per));
EntryATR = ATR(ATR_big_per)[1];
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Checks to ensure all Bars objects contain enough bars before beginning
if (CurrentBars[0] <= BarsRequired)
return;
// Condition for short
if (Close[2] > Close[3] + 1 * TickSize && Close[1] < Close[2] + 1 * TickSize && Close[2] > MAX(Close,5)[2])
{
EnterShortStop(DefaultQuantity, Close[1] - EntryATR, "Short Entry");
}
// Condition for long
if (Close[2] < Close[3] + 1 * TickSize && Close[1] > Close[2] + 1 * TickSize && Close[2] < MIN(Close,5)[2])
{
EnterLongStop(DefaultQuantity, Close[1] + EntryATR, "Long Entry");
}
SetProfitTarget("Long Entry", CalculationMode.Price, EntryATR);
SetStopLoss("Long Entry", CalculationMode.Price, EntryATR, false);
SetProfitTarget("Short Entry", CalculationMode.Price, EntryATR);
SetStopLoss("Short Entry", CalculationMode.Price, EntryATR, false);
}
#region Properties
[Description("Periods for ATR_big")]
[GridCategory("Parameters")]
public int ATR_big_per
{
get { return aTR_big_per; }
set { aTR_big_per = Math.Max(1, value); }
}
#endregion
}
}
1. ERROR: Failed to call method 'Initialize' for strategy 'LWMPws/5e54a411d1b14f9e921192306f114233': В экземпляре объекта не задана ссылка на объект.
From Russian this will be "In an instance of Object reference not set to an object." (translated via Google).
2. Code.Editor.OnLoad: Failed to reference 'NinjaTrader.Custom, Version=7.0.1000.15, Culture=neutral, PublicKeyToken=null': System.IO.FileNotFoundException: Не найден указанный модуль. (Исключение из HRESULT: 0x8007007E)
в System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
в System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
в System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
в System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
в System.Reflection.Assembly.LoadFrom(String assemblyFile)
в NinjaTrader.Code.Editor.OnLoad(Object sender, EventArgs e)

Comment