I want to submit an entry order on a secundary thread, but does not work and Ninjatrader is frozen.
Is there any internal lock inside SubmitOrder() ?
If I replace the function "SubmitOrder" by "Print" works well. So I suspect there is some internal lock. Could you confirm this point?.
Thanks very much.
using System.Threading;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
namespace NinjaTrader.Strategy
{
public class Zs7Borrar01 : Strategy
{
private bool done = false;
protected override void Initialize()
{
Unmanaged = true;
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if ( !Historical && !done )
{
Thread ts = new Thread(threadSubmitEntryOrder);
ts.Start();
ts.Join();
done = true;
}
}
private void threadSubmitEntryOrder()
{
IOrder o = SubmitOrder( 0, OrderAction.Buy, OrderType.Market, 1, 0.0, 0.0, string.Empty, "Compra" );
}
}
}

Comment