actually i am working on own Strategies with Strategy Builder. At the moment i am fine with the possibilities the Strategy Builder supplies, but I want to backtest my strategy intrabar. For that reason I read the already existing topics and helpguides.
Unfortunately I have no programming skills, so I have to ask very basic questions. My main goal is just to unlock a strategy and modifiy it for intrabar backtesting.
First topic:
For understanding issues I downloaded the sample strategy (for NT8). I backtested it and there were no intrabar fills. I looked a longer period back, there were not a single one. (see attached picture)
Is there a general setting I have to change? I haven’t changed the code, so I am a bit irritated. I also used as primary data series the recommended 5 min Chart.
I tested it with and without tick replay enabled.
Order fill resolution = high causes an error.
Strategy: Backtesting NinjaScript Strategies with an intrabar granularity - NinjaTrader Support Forum
Nontheless i read the code and tried to understand it. So there are more questions about outtakes of that code.
2)
AddDataSeries(Data.BarsPeriodType.Minute, 1);
3)
Calculate = Calculate.OnBarClose;
4)
[FONT=Calibri][COLOR=black]protected override void OnBarUpdate()[/COLOR][/FONT] [FONT=Calibri][COLOR=black]{[/COLOR][/FONT] [FONT=Calibri][COLOR=black]if (BarsInProgress == 0)[/COLOR][/FONT] [FONT=Calibri][COLOR=black]{[/COLOR][/FONT] [FONT=Calibri][COLOR=black]if (CrossAbove(EMA(Fast), EMA(Slow), 1))[/COLOR][/FONT] [FONT=Calibri][COLOR=black]EnterLong(1, 1, "Long: 1min");[/COLOR][/FONT] [FONT=Calibri][COLOR=black]}[/COLOR][/FONT]
5) A question to a unlocked Script of Strategy builder:
This part
protected override void OnBarUpdate()
[FONT=Calibri][COLOR=black]{[/COLOR][/FONT] [FONT=Calibri][COLOR=black]if (BarsInProgress != [/COLOR][COLOR=black]0)[/COLOR][/FONT] [FONT=Calibri][COLOR=black]return;[/COLOR][/FONT] [FONT=Calibri][COLOR=black]if (CurrentBars[0] < 1)[/COLOR][/FONT] [FONT=Calibri][COLOR=black]return;[/COLOR][/FONT]
is contained in unlocked strategies. In my mind the BarsInProgress sections of Question 4 and 5 have both the same impact? Is this correct?
And the CurrentBars[0] < 1 is completely missing in Question 4 / Script of the backtest sample. Whats exact the function of this part?
I read the help for currentbar but I am not really sure whats the reason I need this piece of code. If I understand it the right way, the script only continues, if the currentBar is greaterequal 1.
But the very first bar in chart eqals 0. Is this just a filter to start not on the first bar but on the second? (If yes, whats the reason)
Again, I have no programming skills at all and it is really hard to understand the logic if you don’t know where to start.
As you cleary can see, I have struggles to get started and I would be glad about every help I get!
Thank you in advice!
Comment