I'm testing my strategy via Ninjatrader and only using market replay for tests. Sory i can't share my strategy source code here but still I'll try to explain ploblems because i'm fan of this platform.
My strategy source code draft below, i don't share entry/exit rules but you can think these are only true/false flags.
protected override void OnBarUpdate()
{
if (Position.MarketPosition == MarketPosition.Long)
{
if (Long entry exit conditions are met or there is short entry signal)
{
//try exit via SetProfitTarget a few ticks later
SetProfitTarget("Entry", CalculationMode.Price, Close[0] + OrderPlusTicks * TickSize);
}
if (Position.MarketPosition == MarketPosition.Flat)
{
if (Long entry conditions are met)
{
//I'm setting large profit target via SetProfitTarget first(yes i know i can do this once in initialize)
//try enter via EnterLongLimit a few ticks later
EnterLongLimit(OrderQuantity, Close[0] - OrderPlusTicks * TickSize, "Entry");
}
}
}
Notes:
*Above strategy name is MomentumBullStrategy and i write second strategy that name is MomentumBearStrategy for short. Why? because of for simplicity. Ahead i'll combine this two strategy and the result will be the same.
*Strategy initialize contain CalculateOnBarClose = true and ExitOnClose = false;
*I'm testing this strategy ES 2 min chart, i added two strategy same ES 2 min chart and examine results from account performance tab.
Then i changed my code like below-------------------------------------------------------------
protected override void OnBarUpdate()
{
int barOffset = Historical || CalculateOnBarClose ? 0 : 1;
if (FirstTickOfBar && Position.MarketPosition == MarketPosition.Long)
{
if (Long entry exit conditions are met or there is short entry signal)
{
//try exit via SetProfitTarget a few ticks later
SetProfitTarget("Entry", CalculationMode.Price, Close[barOffset] + OrderPlusTicks * TickSize);
}
if (FirstTickOfBar && Position.MarketPosition == MarketPosition.Flat)
{
if (Long entry conditions are met)
{
//I'm setting large profit target via SetProfitTarget first(yes i know i can do this once in initialize)
//try enter via EnterLongLimit a few ticks later
EnterLongLimit(OrderQuantity, Close[barOffset] - OrderPlusTicks * TickSize, "Entry");
}
}
}
Notes:
*I do same changes for MomentumBearStrategy.
*When query entry/exit conditions i'm using barOffset too.
*Strategy initialize contain CalculateOnBarClose = false and ExitOnClose = false;
*I'm testing this strategy ES 2 min chart, i added two strategy same ES 2 min chart and examine results from account performance tab. Absolutely other all testing conditions are same; strategy parameters, time frame, instrument etc.
*Why change this code like this? because of i'll try to after X ticks profit later i set stop loss to breakeven and i want to do this check tick by tick.
* I save performance report, trades and daily period results for both test.
*I have from 2013-06-11 to 30-07-30 market replay data. this is 44 day market data.
Final----------------------------------------------------------------------------------------------------
Results (performans values, order times and types, position entry and exit times, profits, losts etc. are same for 42 days but 2 days a little different. For example one day there is additional one position. Think about it, 44 days 2 min market replay only 2 days diff for both test and only 2 position additionaly. I don't think so i do any error. There is no day specific code, there is no complex strategy, there is no diff parameters etc. I want to repeat again both test result until all the details are same but only 2 day, one each additional only one position.
Final Final

There is no problem for me and for my test because of only 2 addional two position at short time frame. This would not pervert my goal. But i like ninjatrader and i want to help for better product. Also i worry about there is a way send private post that only ninjatrader team see post in this forum?
Sory for long post, have a nice day.

Comment