Just playing around with a little code here, to help myself understand how to program in NT.
The strategy works fine on a backtest until I add the BarsSinceEntry command. I added BarsSinceEntry b/c in the back test, it enters a long position just after getting stopped out.
I'm coding something wrong, any idea what it is?
Here is my code:
protected override void OnBarUpdate()
{
if
// Check that the bond pit is open
(ToTime(Time[0]) > ToTime(8, 30, 0)
&& ToTime(Time[0]) < ToTime(14, 45, 0)
// Check that current position in this strategy is flat
&& Position.MarketPosition == MarketPosition.Flat
// Check for four consecutive down bars
&& Open[3] > Close[3]
&& Open[2] > Close[2]
&& Open[1] > Close[1]
&& Open[0] > Close[0])
{
// Check that we haven't entered a trade in the last two bars.
if (BarsSinceEntry(0, "FourBarStrategy", 0) >2)
// Buy!
EnterLongLimit(Contracts, Close[0], "FourBarStrategy");
Comment