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 Mindset, Today, 11:57 AM
      0 responses
      2 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by marksingh87, 02-13-2024, 04:55 PM
      10 responses
      554 views
      1 like
      Last Post Malletto  
      Started by agilek, 09-13-2021, 08:11 AM
      27 responses
      2,003 views
      0 likes
      Last Post Malletto  
      Started by DayTradingDEMON, 09-10-2024, 08:23 AM
      12 responses
      237 views
      0 likes
      Last Post backtester831  
      Started by jaybedreamin, 01-30-2023, 12:47 AM
      2 responses
      159 views
      0 likes
      Last Post daveleonti1226  
      Working...
      X