I am having trouble implementing a simple parabolic SAR strategy. I am looking to passively follow the signal (long when dots are below price action, short when dots are above price action). I have gotten this to work for the most part, but when back-testing I find a few "switch" signals where the script does nothing. Can anyone tell what is wrong with this snippet? I have walked through the logic step by step, but I cant tell where this is breaking down. I am calculating on each tick.
Thanks in advance!
protected override void OnBarUpdate()
{
//Determine intial position
if (Position.MarketPosition == MarketPosition.Flat)
{
if (ParabolicSAR1[0] < Low[0])
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"Long");
}
else if (ParabolicSAR1[0] > High[0])
{
EnterShort(Convert.ToInt32(DefaultQuantity), @"Short");
}
}
//Stop and reverse signals
if ((Position.MarketPosition == MarketPosition.Long)
&& (ParabolicSAR1[1] < Low[1])
&& (ParabolicSAR1[0] > High[0]))
{
ExitLong(Convert.ToInt32(DefaultQuantity), @"Stop", @"Long");
EnterShort(Convert.ToInt32(DefaultQuantity), @"Short");
}
if ((Position.MarketPosition == MarketPosition.Short)
&& (ParabolicSAR1[1] > High[1])
&& (ParabolicSAR1[0] < Low[0]))
{
ExitShort(Convert.ToInt32(DefaultQuantity), @"Stop", @"Short");
EnterLong(Convert.ToInt32(DefaultQuantity), @"Long");
}

.
Comment