Edgar V.
03-27-2008, 09:23 AM
My strategy is a SMA Crossover with an StochRSI. Problem is that when the SMA crosses over, instead of reversing the order, it duplicate the reverse. I'm not sure what is wrong. I just want to have 1 lot reversing when conditions are met. Below is a sample of my strategy:
if ((SMA(Fast)[0] > SMA(Slow)[0]) && (StochRSI(14)[0] >= 0.8)&& wasLong == false)
{
EnterLong(DefaultQuantity, "LongSMAEnter");
wasLong = true;
}
if ((SMA(Fast)[0] < SMA(Slow)[0])&& wasLong == true)
{
ExitLong("ExitLong", "LongSMAEnter");
wasLong = false;
}
elseif ((SMA(Fast)[0] < SMA(Slow)[0]) && (StochRSI(14)[0] <= 0.2)&& wasLong == true)
{
EnterShort(DefaultQuantity, "ShortSMAEnter");
wasLong = false;
}
if ((SMA(Fast)[0] > SMA(Slow)[0])&& wasLong == false)
{
ExitShort("ExitShort", "ShortSMAEnter");
wasLong = true;
}
if ((SMA(Fast)[0] > SMA(Slow)[0]) && (StochRSI(14)[0] >= 0.8)&& wasLong == false)
{
EnterLong(DefaultQuantity, "LongSMAEnter");
wasLong = true;
}
if ((SMA(Fast)[0] < SMA(Slow)[0])&& wasLong == true)
{
ExitLong("ExitLong", "LongSMAEnter");
wasLong = false;
}
elseif ((SMA(Fast)[0] < SMA(Slow)[0]) && (StochRSI(14)[0] <= 0.2)&& wasLong == true)
{
EnterShort(DefaultQuantity, "ShortSMAEnter");
wasLong = false;
}
if ((SMA(Fast)[0] > SMA(Slow)[0])&& wasLong == false)
{
ExitShort("ExitShort", "ShortSMAEnter");
wasLong = true;
}