After I created my strategy directly in the NinjaScript .
Directly in the NinjaScript I created a new folder named MyStrategies under Strategies folder and then I created my new strategy.
The problem is that after completion succeeded I tried to load my strategy through the Strategies window but I did not see the folder I created and my new strategy.
The logger write “Unable to create instance of NinjaScript …..”
If I close NT and then open it again then I do see my new folder and strategy.
But if I recompiled again the problem returned, I don’t see my folder and my strategy under this folder and logger show “Unable to create instance of NinjaScript …..”
If I drag my strategy file into the main strategy folder “Strategies” recompile it again everything is fine.
If I drag the strategy back from the main folder to my folder, recompile again then again there is a problem.
I think that there is a problem with a namespace.
In addition, if I drag my strategy from my folder to the main folder, open the strategy file
I see that the name space is not updated accordingly
I get "namespace NinjaTrader.NinjaScript.Strategies.MyStrategies”
instead of “NinjaTrader.NinjaScript.Strategies”
If I close the file again and reopen it then namespace updated OK.
Right now I just built an empty strategy that do nothing ,the strategy contains a property of class type only for test
And it also happens.
region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.Indicators;
using NinjaTrader.NinjaScript.DrawingTools;
using NinjaTrader.NinjaScript.Strategies.MyStrategies;
#endregion
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies.MyStrategies
{
public class dbgTest : Strategy
{
public class StgCnfg
{
public int x = 0;
public StgCnfg()
{
this.x = 0;
}
}
//==========================================================================================================================
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "dbgTest";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = true;
RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 100;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
m_StgCnfg = new dbgTest.StgCnfg();
}
else if (State == State.Configure)
{
}
}
protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity,
Cbi.MarketPosition marketPosition, string orderId, DateTime time)
{
}
protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice,
int quantity, int filled, double averageFillPrice,
Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
{
}
protected override void OnBarUpdate()
{
//Add your custom strategy logic here.
}
#region Properties
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "StgConfig", GroupName = "NinjaScriptParameters", Order = 0)]
public dbgTest.StgCnfg m_StgCnfg { set;get;}
#endregion
}
}

Comment