![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
Hallo,
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
bascher,
Could you also post your "Initialize()" section here? It would be helpful so I can assist you further.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
My "Initialize()" section:
protected override void Initialize() { SpreadPlot2(10, 1, 10, Symbol2).Plots[0].Pen.Color = Color.Green; Add(SpreadPlot2(10, 1, 10,Symbol2)); CalculateOnBarClose = true; } |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
bascher,
You aren't adding a second series here so OnBarUpdate() will not be called with a BarsInProgress index other than 0. You would need to add the second series you are trading in order for this strategy to work. http://www.ninjatrader.com/support/h...nstruments.htm
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
Hallo Adam,
thank you for your advise. The problem now is that in the output window occur an additional value. I donīt know where it comes from and what it are representing. I only wrote: Add(Symbol2, PeriodType.Minute, 1); where Symbol2 is a property in the follwing way: [Description("Symbol 2")] [GridCategory("Parameters")] // Force this parameter to be displayed first [Gui.Design.DisplayName("\tSymbol 2")] public string Symbol2 { get { if ((symbol2 == "") && (ChartControl != null) && (Instruments != null)) for (int i = 0; i < ChartControl.BarsArray.Length; i++) if (ChartControl.BarsArray[i].Instrument.FullName != Instruments[0].FullName) { symbol2 = ChartControl.BarsArray[i].Instrument.FullName; break; } return symbol2; } set { symbol2 = value.ToUpper(); } } Without the add statement everything works. Any hints? Thank you in advance. Benjamin |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
Hello,
Thanks for your patience while I reviewed. Unfortunately dynamic properties are not supported and I really do not have a hint for you here. -Brett
Brett
NinjaTrader Customer Service |
|
|
|
![]() |
| Tags |
| enterlong, multi instrument |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Buy/Sell Volume | jerome | Indicator Development | 1 | 12-29-2009 08:07 AM |
| Script is running wild: buy - sell - buy - sell ... | BillCh | Automated Trading | 4 | 02-06-2009 01:01 PM |
| buy sell centered ? | T2020 | Charting | 3 | 10-16-2008 11:20 AM |
| Sound on Buy and Sell | laserjet | General Programming | 3 | 09-30-2008 07:00 PM |
| Buy Sell Indicator | infotrader | Charting | 2 | 01-28-2008 02:12 PM |