Crashed in TicksTick with FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Created at 25 Dec 2021, 08:00
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
sirinath's avatar

sirinath

Joined 25.11.2021

Crashed in TicksTick with FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
25 Dec 2021, 08:00


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TestBot: Robot
    {
        [Parameter(DefaultValue = "AUDCAD,AUDCHF,AUDJPY,AUDNZD,AUDUSD,CADCHF,CADJPY,CHFJPY,EURAUD,EURCAD,EURCHF,EURGBP,EURJPY,EURNZD,EURUSD,GBPAUD,GBPCAD,GBPCHF,GBPJPY,GBPNZD,GBPUSD,NZDCAD,NZDCHF,NZDJPY,NZDUSD,USDCAD,USDCHF,USDJPY")]
        public string InstrumentList { get; set; }

        private readonly TimeFrame timeFrame = TimeFrame.Minute;

        private Bars FindBars(string symbol)
        {
            return MarketData.GetBars(timeFrame, symbol);
        }

        private Ticks FindTicks(string symbol)
        {
            return MarketData.GetTicks(symbol);
        }

        private IEnumerable<PendingOrder> FindPendingOrders(string symbol)
        {
            return from po in PendingOrders
                where po.SymbolName == symbol
                orderby po.TradeType
                select po;
        }

        private IEnumerable<PendingOrder> FindPendingOrders(TradeType tradeType, string symbol)
        {
            return from po in PendingOrders
                where po.SymbolName == symbol && po.TradeType == tradeType
                select po;
        }

        private IEnumerable<PendingOrder> FindPendingOrders(string symbol, string label)
        {
            return from po in PendingOrders
                where po.SymbolName == symbol && po.Label == label
                orderby po.TradeType
                select po;
        }

        private IEnumerable<PendingOrder> FindPendingOrders(TradeType tradeType, string symbol, string label)
        {
            return from po in PendingOrders
                where po.SymbolName == symbol && po.TradeType == tradeType && po.Label == label
                select po;
        }

        private IEnumerable<Position> FindPositions(string symbol)
        {
            return from po in Positions
                where po.SymbolName == symbol
                orderby po.TradeType
                select po;
        }

        private IEnumerable<Position> FindPositions(TradeType tradeType, string symbol)
        {
            return from po in Positions
                where po.SymbolName == symbol && po.TradeType == tradeType
                select po;
        }

        private IEnumerable<Position> FindPositions(string symbol, string label)
        {
            return from po in Positions
                where po.SymbolName == symbol && po.Label == label
                orderby po.TradeType
                select po;
        }

        private IEnumerable<Position> FindPositions(TradeType tradeType, string symbol, string label)
        {
            return from po in Positions
                where po.SymbolName == symbol && po.TradeType == tradeType && po.Label == label
                select po;
        }

        protected override void OnStart()
        {
            Print("Starting");

            Print("Symbols to get: {0}", InstrumentList);
            string[] symbols = InstrumentList.Split(',');

            foreach (string symbol in symbols)
            {
                Print("Registering bar data and tick data handlers for {0}", symbol);
                MarketData.GetBarsAsync(timeFrame, symbol, BarsLoaded);
                MarketData.GetTicksAsync(TicksLoaded);
            }

            Print("Registering pending order event handlers");
            PendingOrders.Created += PendingOrderCreated;
            PendingOrders.Modified += PendingOrderModified;
            PendingOrders.Filled += PendingOrderFilled;
            PendingOrders.Cancelled += PendingOrderCancelled;

            Print("Registering position event handlers");
            Positions.Opened += PositionOpened;
            Positions.Modified += PositionModified;
            Positions.Closed += PositionClosed;

            Print("Started");
        }

        private const int minBars = 6;
        private int barCount = -1;

        private void BarsLoaded(Bars obj)
        {
            string symbol = obj.SymbolName;
            Print("Bars loaded: {0}, Symbol - {1}", obj, symbol);

            int count = Bars.Count;
            if (count <= minBars)
            {
                if (count != barCount)
                {
                    obj.LoadMoreHistoryAsync(LoadedMoreBars);
                    Print("Loading more bars. Count - {0}", count);
                    obj.BarOpened += BarOpenedInit;
                }
            }
            else
            {
                obj.BarOpened += BarOpened;
                Print("Registered bar event handler");
            }

            barCount = count;
        }

        private void LoadedMoreBars(BarsHistoryLoadedEventArgs obj)
        {
            Bars bars = obj.Bars;
            int count = obj.Count;
            string symbol = bars.SymbolName;

            Print("Bars loaded: {0}, Bars - {1}, Count - {2}, Symbol - {3}", obj, bars, count, symbol);

            if (count <= minBars)
            {
                if (count != barCount)
                {
                    bars.LoadMoreHistoryAsync(LoadedMoreBars);
                    Print("Loading more bars. Count - {0}", count);
                    bars.BarOpened -= BarOpenedInit;
                    bars.BarOpened += BarOpenedInit;
                }
            }
            else
            {
                bars.BarOpened -= BarOpenedInit;
                bars.BarOpened += BarOpened;
                Print("Registered bar event handler");
            }

            barCount = count;
        }

        private const int minTicks = 0;
        private int tickCount = -1;

        private void TicksLoaded(Ticks obj)
        {
            string symbol = obj.SymbolName;
            Print("Ticks loaded: {0}, Symbol - {1}", obj, symbol);

            int count = obj.Count;
            if (count <= minTicks)
            {
                if (count != tickCount)
                {
                    obj.LoadMoreHistoryAsync(LoadedMoreTicks);
                    Print("Loading more ticks. Count - {0}", count);
                    obj.Tick += NewTicksInit;
                }
            }
            else
            {
                obj.Tick += NewTicks;
                Print("Registered tick event handler");
            }

            tickCount = count;
        }

        private void LoadedMoreTicks(TicksHistoryLoadedEventArgs obj)
        {
            Ticks ticks = obj.Ticks;
            int count = obj.Count;
            string symbol = ticks.SymbolName;

            Print("Ticks loaded: {0}, Ticks - {1}, Count - {2}, Symbol - {3}", obj, ticks, count, symbol);

            if (count <= minTicks)
            {
                if (count != tickCount)
                {
                    ticks.LoadMoreHistoryAsync(LoadedMoreTicks);
                    Print("Loading more ticks. Count - {0}", count);
                    ticks.Tick -= NewTicksInit;
                    ticks.Tick += NewTicksInit;
                }
            }
            else
            {
                ticks.Tick -= NewTicksInit;
                ticks.Tick += NewTicks;
                Print("Registered tick event handler");
            }

            tickCount = count;
        }

        private void BarOpenedInit(BarOpenedEventArgs obj)
        {
            Bars bars = obj.Bars;
            string symbol = bars.SymbolName;
            Print("Initialize - Bar opened: Event - {0}, Bars - {1}, Symbol - {2}, Trader Type - {3}", obj, bars, symbol);

            int count = bars.Count;
            if (count > minBars)
            {
                bars.BarOpened -= BarOpenedInit;
                bars.BarOpened += BarOpened;
                Print("Registered bar event handler");
            }
        }

        private void BarOpened(BarOpenedEventArgs obj)
        {
            Bars bars = obj.Bars;
            string symbol = bars.SymbolName;
            Print("Bar opened: Event - {0}, Bars - {1}, Symbol - {2}, Trader Type - {3}", obj, bars, symbol);

            CalculateAndPlaceOrders(symbol);
        }

        private void NewTicksInit(TicksTickEventArgs obj)
        {
            Ticks ticks = obj.Ticks;
            string symbol = ticks.SymbolName;
            Print("Initialize - New ticks: Event - {0}, Ticks - {1}, Symbol - {2}, Trader Type - {3}", obj, ticks, symbol);

            int count = ticks.Count;
            if (count > minTicks)
            {
                ticks.Tick -= NewTicksInit;
                ticks.Tick += NewTicks;
                Print("Registered tick event handler");
            }
        }

        private void NewTicks(TicksTickEventArgs obj)
        {
            Ticks ticks = obj.Ticks;
            string symbol = ticks.SymbolName;
            Print("New ticks: Event - {0}, Ticks - {1}, Symbol - {2}, Trader Type - {3}", obj, ticks, symbol);
        }

        private void PendingOrderCreated(PendingOrderCreatedEventArgs obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Pending order created: Event - {0}, Pending Order - {1}, Symbol - {2}, Trader Type - {3}", obj, pendingOrder, symbol, tradeType);
        }

        private void PendingOrderModified(PendingOrderModifiedEventArgs obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Pending order modified: Event - {0}, Pending Order - {1}, Symbol - {2}, Trader Type - {3}", obj, pendingOrder, symbol, tradeType);
        }

        private void PendingOrderCancelled(PendingOrderCancelledEventArgs obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Pending order canceled: Event - {0}, Pending Order - {1}, Symbol - {2}, Trader Type - {3}", obj, pendingOrder, symbol, tradeType);
        }

        private void PendingOrderFilled(PendingOrderFilledEventArgs obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Pending order filled: Event - {0}, Pending Order - {1}, Position - {2}, Symbol - {3}, Trader Type - {4}", obj, pendingOrder, position, symbol, tradeType);
        }

        private void PositionOpened(PositionOpenedEventArgs obj)
        {
            Position position = obj.Position;
            string symbol = position.SymbolName;
            TradeType tradeType = position.TradeType;

            Print("Position opened: Event - {0}, Position - {1}, Symbol - {2}, Trader Type - {3}", obj, position, symbol, tradeType);
        }

        private void PositionModified(PositionModifiedEventArgs obj)
        {
            Position position = obj.Position;
            string symbol = position.SymbolName;
            TradeType tradeType = position.TradeType;

            Print("Position modified: Event - {0}, Position - {1}, Symbol - {2}, Trader Type - {3}", obj, position, symbol, tradeType);
        }

        private void PositionClosed(PositionClosedEventArgs obj)
        {
            Position position = obj.Position;
            PositionCloseReason reason = obj.Reason;
            string symbol = position.SymbolName;
            TradeType tradeType = position.TradeType;

            Print("Position closed: Event - {0}, Position - {1}, Reason - {2}, Symbol - {3}, Trader Type - {4}", obj, position, reason, symbol, tradeType);
        }

        private void ExecuteMarketOrderTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Market order result: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void ExecuteMarketRangeOrderTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Market range order result: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void PlaceLimitOrderTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Limit order placement result: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void PlaceStopOrderTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Stop order placement result: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void PlaceStopLimitOrderTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Stop-limit order placement result: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void ModifyPendingOrderTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Order modification result: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void CancelPendingOrderTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = pendingOrder.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Pending order cancellation result: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void ModifyPositionTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = position.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Position modified: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void ReversePositionTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = position.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Position reversed: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        private void ClosePositionTradeResult(TradeResult obj)
        {
            PendingOrder pendingOrder = obj.PendingOrder;
            Position position = obj.Position;
            bool isSuccessful = obj.IsSuccessful;
            ErrorCode? errorCode = obj.Error;
            string symbol = position.SymbolName;
            TradeType tradeType = pendingOrder.TradeType;

            Print("Position closed: Trade Result - {0}, Pending Order - {1}, Position - {2}, Is Successful - {3}, Error - {4}, Symbol - {5}, Trader Type - {6}", obj, pendingOrder, position, isSuccessful, errorCode, symbol, tradeType);
        }

        protected override void OnStop()
        {
            Print("Bot Stopped");
        }

        protected override void OnError(Error error)
        {
            ErrorCode errorCode = error.Code;
            TradeResult tradeResult = error.TradeResult;
            PendingOrder pendingOrder = tradeResult.PendingOrder;
            Position position = tradeResult.Position;
            bool isSuccessful = tradeResult.IsSuccessful;
            ErrorCode? tradeResultErrorCode = tradeResult.Error;
            string symbol = pendingOrder != null ? pendingOrder.SymbolName : position.SymbolName;
            TradeType tradeType = pendingOrder != null ? pendingOrder.TradeType : position.TradeType;

            Print("Error raised: Error - {0}, Code - {1}, Trade Result - {2}, Pending Order - {3}, Position - {4}, Is Successful - {5}, Trade Result Error - {6}, Symbol - {7}, Trader Type - {8}", error, errorCode, tradeResult, pendingOrder, position, isSuccessful, tradeResultErrorCode, symbol, tradeType);
        }

        private readonly Dictionary<string, TradeType?> directions = new Dictionary<string, TradeType?>();

        private void CalculateAndPlaceOrders(string symbol)
        {
            Bars bars = FindBars(symbol);
            IEnumerable<PendingOrder> pendingOrders = FindPendingOrders(symbol);
            IEnumerable<Position> positions = FindPositions(symbol);
            TradeType? direction = directions[symbol];
            Print("Calculate & Place Orders: Bars - {0}, Pending Order - {1}, Positions - {2}, Direction - {3}", bars, pendingOrders, positions, direction);

            // More code
        }
    }
}

I am getting the following exception:

12/11/2012 03:30:54.900 | Crashed in TicksTick with FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Also am I using the cTrader API right as I am still leaning the ropes.

Also how can I improve the above code?

Full log:

12/11/2012 03:30:54.900 | Backtesting was stopped
12/11/2012 03:30:54.900 | Bot Stopped
12/11/2012 03:30:54.900 | Crashed in TicksTick with FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
12/11/2012 03:30:54.872 | Bars loaded: cAlgo.API.BarsHistoryLoadedEventArgs, Bars - AUDCHF, Minute, Count - 0, Symbol - AUDCHF
12/11/2012 03:30:48.682 | Loading more bars. Count - 0
12/11/2012 03:30:48.682 | Bars loaded: cAlgo.API.BarsHistoryLoadedEventArgs, Bars - AUDCHF, Minute, Count - 0, Symbol - AUDCHF
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: GBPAUD, Minute, Symbol - GBPAUD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: EURUSD, Minute, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: EURJPY, Minute, Symbol - EURJPY
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: EURGBP, Minute, Symbol - EURGBP
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: EURCHF, Minute, Symbol - EURCHF
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: EURAUD, Minute, Symbol - EURAUD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: CHFJPY, Minute, Symbol - CHFJPY
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: CADJPY, Minute, Symbol - CADJPY
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: CADCHF, Minute, Symbol - CADCHF
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: AUDUSD, Minute, Symbol - AUDUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Bars loaded: AUDJPY, Minute, Symbol - AUDJPY
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.783 | Loading more bars. Count - 2
12/11/2012 03:30:47.783 | Bars loaded: AUDCHF, Minute, Symbol - AUDCHF
12/11/2012 03:30:47.783 | Registered tick event handler
12/11/2012 03:30:47.783 | Ticks loaded: EURUSD, Tick, Symbol - EURUSD
12/11/2012 03:30:47.690 | Started
12/11/2012 03:30:47.690 | Registering position event handlers
12/11/2012 03:30:47.690 | Registering pending order event handlers
12/11/2012 03:30:47.690 | Failed to get symbol 'USDJPY': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for USDJPY
12/11/2012 03:30:47.690 | Failed to get symbol 'USDCHF': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for USDCHF
12/11/2012 03:30:47.690 | Failed to get symbol 'USDCAD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for USDCAD
12/11/2012 03:30:47.690 | Failed to get symbol 'NZDUSD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for NZDUSD
12/11/2012 03:30:47.690 | Failed to get symbol 'NZDJPY': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for NZDJPY
12/11/2012 03:30:47.690 | Failed to get symbol 'NZDCHF': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for NZDCHF
12/11/2012 03:30:47.690 | Failed to get symbol 'NZDCAD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for NZDCAD
12/11/2012 03:30:47.690 | Failed to get symbol 'GBPUSD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for GBPUSD
12/11/2012 03:30:47.690 | Failed to get symbol 'GBPNZD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for GBPNZD
12/11/2012 03:30:47.690 | Failed to get symbol 'GBPJPY': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for GBPJPY
12/11/2012 03:30:47.690 | Failed to get symbol 'GBPCHF': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for GBPCHF
12/11/2012 03:30:47.690 | Failed to get symbol 'GBPCAD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for GBPCAD
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for GBPAUD
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for EURUSD
12/11/2012 03:30:47.690 | Failed to get symbol 'EURNZD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for EURNZD
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for EURJPY
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for EURGBP
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for EURCHF
12/11/2012 03:30:47.690 | Failed to get symbol 'EURCAD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for EURCAD
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for EURAUD
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for CHFJPY
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for CADJPY
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for CADCHF
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for AUDUSD
12/11/2012 03:30:47.690 | Failed to get symbol 'AUDNZD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for AUDNZD
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for AUDJPY
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for AUDCHF
12/11/2012 03:30:47.690 | Failed to get symbol 'AUDCAD': symbol has no quotes.
12/11/2012 03:30:47.690 | Registering bar data and tick data handlers for AUDCAD
12/11/2012 03:30:47.690 | Symbols to get: AUDCAD,AUDCHF,AUDJPY,AUDNZD,AUDUSD,CADCHF,CADJPY,CHFJPY,EURAUD,EURCAD,EURCHF,EURGBP,EURJPY,EURNZD,EURUSD,GBPAUD,GBPCAD,GBPCHF,GBPJPY,GBPNZD,GBPUSD,NZDCAD,NZDCHF,NZDJPY,NZDUSD,USDCAD,USDCHF,USDJPY
12/11/2012 03:30:47.690 | Starting
12/11/2012 03:30:47.690 | Backtesting started

 


@sirinath
Replies

firemyst
26 Dec 2021, 14:19

Of course it crashed where it says it did :-)

Look at your code there:

 

private void NewTicks(TicksTickEventArgs obj)
        {
            Ticks ticks = obj.Ticks;
            string symbol = ticks.SymbolName;
            Print("New ticks: Event - {0}, Ticks - {1}, Symbol - {2}, Trader Type - {3}", obj, ticks, symbol);
        }

 

Look at your print statement. How many variables are you trying to print? And how many do you have listed as parameters?

 

:-)

 


@firemyst