Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Continued: Automated Trading German Stocks

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Continued: Automated Trading German Stocks

    Hi,

    this refers to the discussion from yesterday - the suggested solution using NT 6.5beta does not make a difference.

    I am still getting the following error message:

    12/6/2007 12:09:15 AM,Strategy,The strategy 'DataLoad' has called the Add() method with an invalid instrument. Either 'DBK' does not exist in the Instrument Manager or the specified exchange has not been configured.

    I am already trading the NDX100 without any problems. Everything is configured the same way for the German stocks, except for the Exchange (Xetra).

    This issue has to be solved quickly as it is preventing trading a profitable strategy for 3 days now. Please refer to the thread from Tuesday
    [Ticket #46550] / "Running a Strategy on German Stocks with Interactive Brokers"


    Thanks
    Martin

    #2
    Code Snippets regarding Trade Automation Problem

    There is a notable difference from NT6.5 vs. 6.0 though:
    when displaying a chart with one of the German instruments using Xetra as exchange, this triggers a data request to Interactive Brokers. I guess this means that my instrument list for the HDAX stocks seems to be fine. Hence the problem must lie in the way in which the strategy accesses the data.

    The respective strategy is used simply to trigger a historical data request for IB (I have separated that from the actual strategy in order not to trigger IBs limitations on historical data requests), and is working perfectly fine for NDX100 stocks:

    In the "Strategy" tab, it is simply called using the MarketListIdx Number referring to lists of symbols defined in UserDefinedMethods:


    Definition of Customer MarketLists in UserDefinedMethods
    public string[][] MarketLists = {
    new string[] {"AAPL", "ADBE", "ADSK", "AKAM"},
    new string[] {"ADS", "ALV", "DBK", "DAI"}
    };

    Complete Code of 'DataLoad' Strategy
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Strategy;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Does nothing, except loading data from IB
    /// </summary>
    [Description("Does nothing, except loading data from IB")]
    [Gui.Design.DisplayName("Data Load Strategy")]
    public class DataLoad : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int marketListIdx = 0; // Default setting for MarketListIdx
    private int lookbackLength = 390; // Default setting for LookbackLength
    // User defined variables (add any user defined variables below)
    string[] marketList;
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    // Sanity Check
    if( marketListIdx < 0 || marketListIdx >= MarketLists.Length )
    {
    Print("Invalid marketListIdx");
    return;
    }
    // Market initialization
    marketList = MarketLists[marketListIdx];
    for( int i=0; i<marketList.Length; ++i )
    {
    Log("Using Instrument " + marketList[i],NinjaTrader.Cbi.LogLevel.Information);
    Print("Adding " + marketList[i]);
    Add(marketList[i],PeriodType.Minute,1);
    }

    // Set further Ninja configuration variables
    DataSeriesConfigurable = false; // this doesn't seem to have any effect so we just ignore
    // the manually assigned data series
    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    double x = SMA(LookbackLength)[0];
    }


    #region Properties
    [Description("Choose Symbol List")]
    [Category("Parameters")]
    public int MarketListIdx
    {
    get { return marketListIdx; }
    set { marketListIdx = Math.Max(0, value); }
    }

    [Description("Length of Data Download")]
    [Category("Parameters")]
    public int LookbackLength
    {
    get { return lookbackLength; }
    set { lookbackLength = Math.Max(390, value); }
    }
    #endregion
    }
    }

    Comment


      #3
      Sent you PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bmartz, 03-12-2024, 06:12 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by Aviram Y, Today, 05:29 AM
      4 responses
      13 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by cls71, Today, 04:45 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X