SamIam
08-28-2007, 08:17 PM
Greetings,
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:
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void 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
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:
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void 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