I am creating some custom series and I just want to make sure I am referencing the correct bar.
As I understand, every series starts with bar 0, so in my code below am I right in thinking that, even if my calculation is on IsFirstTickOfBar, the first value of the HSwPrice series is [0], so with i = 1, the first value of the series would be [i - 1]?
Also, am I synchronising correctly the HSwPrice series to the 5 minute series in DataLoaded?
According to the help guide (SampleSyncSecondarySeries_NT8):
" /* Syncs another DataSeries object to the secondary bar object.
We use an arbitrary indicator overloaded with an ISeries<double> input to achieve the sync.
The indicator can be any indicator. The Series<double> will be synced to whatever the
BarsArray[] is provided.*/ "
Thank you
secondarySeries = new Series<double>(SMA(BarsArray[1], 50)); // [URL="https://ninjatrader.com/support/helpGuides/nt8/samples/SampleSyncSecondarySeries_NT8.zip"]SampleSyncSecondarySeries_NT8[/URL] code
public class ATM2 : Strategy { private Series<double> HSwPrice; // High price swing ...... else if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Tick, 1); AddDataSeries(Data.BarsPeriodType.Minute, 5); } else if (State == State.DataLoaded) { HSwPrice = new Series <double>(DMI(Closes[2], Convert.ToInt32(DmiPeriod)), MaximumBarsLookBack.TwoHundredFiftySix); ....... if (IsFirstTickOfBar) { while (!DoneSearching) { i = 1; if (Highs[2][i] < Highs[2][i+1] && Highs[2][i+1] > Highs[2][i+2]) { HSwPrice[i - 1] = Highs[2][i + 1]; // Finding high price swings HSwPriceBar = CurrentBar - (i+1); }
Comment