Hi Everyone,
I am creating a strategy where a specific point is analyzed for the price, and an order is placed at a specific level. If the price approaches the order but it is not executed, the order is moved to another point. However, when I try to enable the strategy, I receive an error indicating issues with the SubmitOrderUnmanaged method.
Can you help me?
My Code
protected override void OnBarUpdate()
{
if (CurrentBar < 1 || State != State.Realtime)
return;
dailyHigh = Math.Max(dailyHigh, High[0]);
dailyLow = Math.Min(dailyLow, Low[0]);
entryPriceSell = dailyHigh + 10 * TickSize;
entryPriceBuy = dailyLow - 10 * TickSize;
if (double.IsNaN(entryPriceSell) || double.IsNaN(entryPriceBuy))
return;
if (Position.MarketPosition == MarketPosition.Flat)
{
CancelAllPendingOrders();
SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, 1, entryPriceSell, 0, "", "SellLimit");
SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Limit, 1, entryPriceBuy, 0, "", "BuyLimit");
}
// Plota linhas de preço
PlotOrderLines();
}
Thanks a lot!

Comment