I am having this problm with all the strategies that I have built in NT. When I start the strategy it right away shows an unrealized gain/loss in the strategy tab. But the strategy does not execute any order. When the opposite condition meets, the strategy not only initiate a new position but also close the unopened position. In this case I ends up with two lots instead of one.
Is there any condition I have to incorporate to avoid this from happening?
Can I force the strategy to right-away place an order if any of the condition in the code is true at the time strategy gets started?
Below is one of the codes that is behaving in this manner:
protectedoverridevoid Initialize()
{
CalculateOnBarClose = true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Condition set 1
if (Close[0] > MAX(High,periodOpen)[1])
{
EnterLong(1, "Long");
}
// Condition set 2
if (Close[0] < MIN(Low,periodOpen)[1])
{
EnterShort(1, "Short");
}
// Condition set 3
if (Close[0] < MIN(Low,periodClose)[1])
{
ExitLong("Exit Long", "Long");
}
// Condition set 4
if (Close[0] > MAX(High,periodClose)[1])
{
ExitShort("Exit Short", "Short");
}
}
Thanks,
Sami
Comment