I've built a swing indicator that looks for swing points, which is working fine.
I'm now trying to back test a few ideas with this swing indicator, but I'm having some issues on getting the historical entries right.
Here is an example of a short signal. A short swing is defined as a bar with a higher high than the bars on either side of it, and the signal bar to the left of the swing high bar must have a lower low than the swing high bar. Here's a chart.
Look at the highest bar on this chart...the one that has the arrow, triangle and dot on top of it with the pink colored bar to the right of it. That's the swing high bar and the pink bar is the bar that confirmed the swing high.
So I want to test a simple always in the market system (I'll added exits later) to get the backtesting functionality down. So on this trade, I want my short entry price to be at the level the blue line is drawn at, which is 1 tick below the low of the swing high bar. In this particular case, the swing high bar's low was 100.35, so the short entry price would be 100.34.
As you can see, the position is filled one bar to the right of the pink signal bar at the correct price, but I want the backtest to assume that the entry is made at 100.34 within the pink bar.
To do this, I added a secondary series within Initialize() by:
Add(PeriodType.Minute, 1);
#region GoShort()
private void GoShort()
{
//Enter Position
myEntryOrder = EnterShortLimit(1, true, contracts, e, "short");
DrawLine("entry line" + CurrentBar, 1, e, 0, e, Color.Blue);
Print("We are now done with the GoShort() Method, and we have successfully submitted a short market order.");
}
#endregion GoShort()
The GoShort() method was called from within a BIP == 0 if statement within OnBarUpdate().
I know that I will have other questions, but before I do anything else I would like to first focus on getting the strategy to execute an order within the correct signal bar. What am I doing wrong? I believe the blue line shows that I have am correctly focused on the signal bar (ie, I'm attempting to EnterShortLimit on the right bar), but the order is not getting filled until the next bar, which is not correct. In realtime, this order would have fired once the swing high was confirmed, which would have been at the point that the low of the swing high bar was taken out by the signal bar's low (ie, at the entry point), which would have triggered GoShort(), which would have fired a real time order off, which would have been filled when market conditions allowed.
What am I missing?
Thanks,
Aventeren

Comment