I have strategy that works well in Thinkorswim but is not working in Ninjatrader. I have attached my two indicators and the strategy. It seems to enter the long but it immediately closes the long despite the fact that the conditions to exit are not there. So if a rally is going on it keeps entering and exiting.
Any ideas would be appreciated.
Here is order code:
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 2)
return;
C1 = Close[0];
C2 = Close[1];
t1 = WaddahAttarExplosion1.Histogram1[0];
t1Prev = WaddahAttarExplosion1.Histogram1[1];
t1dn = WaddahAttarExplosion1.Histogram2[0];
ex = WaddahAttarExplosion1.Line1[0];
Print("T1dn: " + t1dn);
Print("T1: " + t1);
Print("EX: " + ex);
if (t1 > 0 && t1 > ex && t1Prev > 0)
{
TrendUp = 1;
}
else
TrendUp = 0;
if (t1dn > 0 )
{
TrendDown = 1;
}
else if (t1dn == 0)
{
TrendDown = 0;
}
if (C1 < (C2*.99962))
{
trailStopLoss = 1;
}
// BullPower Signal
BullPower1 = RayBullPower1.Histogram1[0];
BearPower1 = RayBullPower1.Histogram2[0];
if (BullPower1 > 1.0)
{
BullPowerBuy = 1;
}
if (BearPower1 < 0 )
{
BullPowerSell = 1;
}
if (MACD1.Diff[1] < MACD1.Diff[2] && Close[1] < Close[2] && Close[0] > High[1])
{
MacdLow = 1;
Draw.ArrowUp(this, "BULL", true, 0, Low[0] - TickSize, Brushes.Green);
}
if (MACD1.Diff[1] > MACD1.Diff[2] && Close[1] > Close[2] && Close[0] > Low[1])
{
MacdHighBear = 1;
Draw.ArrowDown(this, "BEAR", true, 0, Low[0] - TickSize, Brushes.Red);
}
if (TrendUp == 1 && BullPowerBuy == 1 && MacdLow == 1 && TrendDown == 0)
{
EnterLong(DefaultQuantity, "@Long");
}
if (TrendDown == 1 || BullPowerSell == 1 ||MacdHighBear == 1) //|| (trailStopLoss == 1))
{
ExitLong(Convert.ToInt32(DefaultQuantity), @"CloseLong", "");
}
Comment