I'm attempting to run multiple instruments through a single strategy. As an example, I would like to use the stochastics oscillator but pass different values of D's and K's for each instrument in a single script .I'm using the 'add' function in the initialize to add the different instruments to the script. Is this doable? Can you show me the proper form for using the stochastic oscillator on different bars arrays? Thank you.
protectedoverridevoid Initialize()
{
Add("AAPL", PeriodType.Minute, 60);
Add("AIG", PeriodType.Minute, 60);
CalculateOnBarClose = true;
}
protectedoverridevoid OnBarUpdate()
{
if (Stochastics(BarsArray[2],7, 14, 3).D[0] < Variable0)
{
nShares = (int) (1000/High[2]);
EnterLong(nShares,"BuyMkt2");
}
if (Stochastics(BarsArray[2],6, 15, 3).D[0] < Variable1)
{
nShares = (int) (1000/High[2]);
EnterLong(nShares,"BuyMkt2");
}
}
Comment