Brussels / Dublin
Experience: Intermediate
Platform: ninjatrader
Trading: Stdev + 2
Posts: 468 since Jun 2010
Thanks Given: 844
Thanks Received: 595
|
Hi,
Using Closes[1][0] && Closes[0][0] aswell as Times[0][0] && Times[1][0].
I have two instruments (which are similiar but on different markets).
Example: 1 = Euronext Milling Wheat Futures (Traded in europe) and 2 = Wheat (Traded on GLOBEX).
In this example i want to compare the price of european milling wheat versus wheat in the US. So i have put together an indicator to do this however i am facing a pretty common issue which im sure other's have seen.
Timeframe is 1 minute for both as i dont need to be blatantly high frequency.
But when i compare the bar's they do not always overlap on the right days / times reason being there are obviously holidays in states that are not in EU. My own PC runs eastern time so at least Times compares just eastern time.
I took a look at the correlation indicator on the forum and seen the following embedded into the onbarupdate and was thinking this might suffice if i take this code hack it and just wrap it at the start of my code and place a try whenever the timestamp's actually lineup. :
if( CurrentBars[0]<window || CurrentBars[1] < window ||(Closes[0].Count < window) || (Closes[1].Count < window) ) return;
double[] signalA = new double[window];
double[] signalB = new double[window];
int count = window;
for (int index = 0; index < count; index++)
{
if (null != Closes[0][index] && null != Closes[1][index]) {
double currentAClose = Closes[0][index];
signalA[index] = currentAClose;
double currentBClose = Closes[1][index];
signalB[index] = currentBClose;
} else {
Print("Corr - Missing bar, disregarding");
}
}
Is there a better way to do this that im not thinking of as id like the code to be as succinct as possible?
|