I have got a multi instrument strategy and the following code snippet:
protected override void OnBarUpdate()
{
// Is this necessary to verify the instrument 1 and 2??
if (BarsInProgress == 0)
{
double beta = SpreadPlot2(10,1,10,Symbol2).Beta;
double betage = Math.Round(beta,2);
double factor = betage*10;
int factorint = Convert.ToInt32(factor);
// Condition 1
if (CrossBelow(SpreadPlot2(10, 1, 10, Symbol2).Value, Variable0, 1))
{
string ausgabe = string.Format("Beta = {0}",beta);
Print(ausgabe);
Print(factorint);
// EnterLong(int barsInProgressIndex, int quantity, string signalName) e.g. EnterLong(0, 100, "BUY MSFT");
// Sell 10 x instrument 1
EnterShort(0,10,"SELL $NZDUSD");
// Buy factorint x instrument 2
EnterLong(1,factorint, "Buy $USDCAD");
}
// Condition 2
else if (CrossAbove(SpreadPlot2(10, 1, 10, Symbol2).Value, Variable1, 1))
{
Print("CrossAbove -2");
EnterLong(0,10,"BUY $NZDUSD");
EnterShort(1,factorint, "Sell $USDCAD");
}
}
}
There happens nothing but the following error occurs:
**NT** Error on calling 'OnBarUpdate' method for strategy 'Residual/': 'EnterLong': 'barsInProgressIndex' parameter out of valid range 0 to 0, was 1
What I have to change?
Thank you in advance for your effort.
Best regards
Benjamin

Comment