I'm new to NT and have an idea for a swingtrading strategy I would like to backtest in NT.
The basic idea of the strategy is quite simple; to go long at todays close when FastStochastics(1,2) is less than 10, and exit when FastStocastics(1,2) is more than 50.
Now to the problem: I would like to backtest this strategy based on DAILY data (OHLC), since I do not have access to more granular data. I know this will give a hypothetical result since you cannot actually buy at the close price. However, I would like the backtesting to be done with daily OHLC data, and if the right conditions are met, I would like NT to buy at the theoretical Close price, and sell at the theoretical close price when my conditions are met. Is this possible in NT? How?
My current code is like this:
protected override void Initialize()
{
CalculateOnBarClose = true;
Add(StochasticsFast(1, FastK));
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (StochasticsFast(1, FastK).D[0] < FastKBuy)
{
EnterLong(DefaultQuantity, "Buy");
}
// Condition set 2
if (StochasticsFast(1, FastK).D[0] > FastKSell)
{
ExitLong("Exit", "Sell");
}
}
With the current code, the order is placed the next day, which is not what I want.
Regards
/ Johan
Comment