I am working with a strategy that has a SMA crossover on 2 averages. I have it set to Calculate on bar close FALSE.
Right now, upon enabling, it pretty much enters a trade long or short if I choose FALSE depending on if the crossover is bullish or bearish immediately.
I have Wait until flat before executing live set in the Options by the way too...
Also, I have if (Historical) return; included too...
When I have it set to TRUE this is not a issue...only when it is set to FALSE is this a issue.
Here is what I would like to prevent it from doing...upon enabling the strategy when it is set to FALSE, I only want it to take trades once the crossovers actually touch or cross.
Here is the basic set up as an example for a long:
protected override void OnBarUpdate()
{
if (Historical) return;
if (Position.MarketPosition == MarketPosition.Flat)
if(FirstTickOfBar)
{
x = 0;
}
if (BarsInProgress != 0)
return;
if (CrossAbove(SMA(Fast), SMA(Slow), 1)
&& x < myTradeCounter
&& (EMA(BarsArray[1], 1)[0] > EMA(BarsArray[1], 3)[0]
&& EMA(BarsArray[2], 1)[0] > EMA(BarsArray[2], 3)[0]))
{
EnterLong(DefaultQuantity, "BuyMkt");
x++;
}
No matter how far away the crossover has happened long or short, upon enabling, it would just immediately go long or short when I have it set to FALSE. However, once enabled and the first signal is out of the way, then it runs perfectly. My issue is when it initially enables for the first time.
Please let me know what I need to include to ensure signal executions only fire upon the crossovers actually touching/crossing when using Calculate on bar close FALSE...?
Thanks folks

Greg

Comment