The position starts flat entering the 10:06 bar. It buys one contract then another, sells one then sells the other. Then it proceeds to do it all over again, all in the 10:06 candle. A chart visual of this is in Pic2.
I might add an EntriesPerDirection instruction to control this, but I should have wrapped the code in enough layers to prevent it from over ordering. What I'm doing isn't working. I don't have a clue why.
Here's a code summary:
if (FirstTickOfBar)
{
currentbar = CurrentBar;
....... stop and exit logic
}
// These statements are part of the OnBarUpdate method
if (Position.MarketPosition == MarketPosition.Long)
if ((Close[0] - Position.AvgPrice) >= targetprofit) //Hit Max Profit
{
ExitLong();
....exit_bar = currentbar;
....
}
}
if (FirstTickOfBar)
{
//Trying to enter an UP trade
if (enteronbar < currentbar) //redundant
// This statement keeps it from reentering on the same bar if it has entered then exited in the same bar
if (Position.MarketPosition == MarketPosition.Flat)
// This statement keeps it from entering on the next bar if not flat
if (currentbar > exit_bar)
// This statement keeps it from exiting then renetering on the same bar if the exit bar is not the entry bar
....more logic......
enteronbar = currentbar;
SetStopLoss(CalculationMode.Price, (Close[0] - initial_stop));
EnterLong();
}
So, with all that "don't-trade" logic, it trades like crazy.
Any ideas?
Thanks,
Larry

Comment