Here LE = calculated long entry price and SE = calculated short entry price.
These levels are constant through out the trading session.
protectedoverridevoid Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, Target);
SetStopLoss("", CalculationMode.Ticks, InitialStop, false);
CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
if (CurrentBar < 1)
return;
if (CurrentBar > 1)
{
if (Bars.FirstBarOfSession)
{
myLongEntryOrder = null;
myShortEntryOrder = null;
LE = Open[0] – 10 *TickSize;
SE = Open[0] + 10 *TickSize;
}
if (Position.MarketPosition == MarketPosition.Flat && LE > 0 && Low[0] > LE)
{
myLongEntryOrder = EnterLongLimit(LE);
}
if (Position.MarketPosition == MarketPosition.Flat && SE > 0 && High[0] < SE)
{
myShortEntryOrder = EnterShortLimit(SE);
}
}
protected override void OnOrderUpdate(IOrder order)
{
if (myLongEntryOrder != null && myLongEntryOrder == order)
{
if (order.OrderState == OrderState.Filled)
{myLongEntryOrder = null;}
}
if (myShortEntryOrder != null && myShortEntryOrder == order)
{
if (order.OrderState == OrderState.Filled)
{myShortEntryOrder = null;}
}
if (ToTime(Time[0]) == ToTime(15, 10, 0))
{
myLongEntryOrder = null;
myShortEntryOrder = null;
}
}
I got an error with taking trades on one direction. What is the problem on code?
Any suggestions? Please help?

Comment