Debugging cAlgo BOT using Visual Studio does not initialize Indicators such as EMA
Debugging cAlgo BOT using Visual Studio does not initialize Indicators such as EMA
19 Jan 2014, 23:00
Problem: Indicators such as EMA are returning null values even after initialization while debugging.
I have been working on getting the Visual Studio debugger to debug a sample BOT code I've written. I compiled the following code into a dll first using Visual Studio.
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using System.Collections;
using System.Collections.Generic;
namespace Rsi.TradeLibrary
{
[Robot(TimeZone = TimeZones.UTC)]
public class SampleBot : Robot
{
//Global Variables
[Parameter("MA Type")]
public MovingAverageType MAType { get; set; }
[Parameter("Source")]
public DataSeries SourceSeries { get; set; }
[Parameter("Slow Periods", DefaultValue = 20)]
public int SlowPeriods { get; set; }
[Parameter("Fast Periods", DefaultValue = 10)]
public int FastPeriods { get; set; }
public ExponentialMovingAverage slowMa;
public ExponentialMovingAverage fastMa;
protected override void OnStart()
{
Print("Debugging Started");
FastPeriods = 10;
SlowPeriods = 20;
fastMa = Indicators.ExponentialMovingAverage(SourceSeries, FastPeriods);
slowMa = Indicators.ExponentialMovingAverage(SourceSeries, SlowPeriods);
}
}
}
I then referenced the dll in cAlgo IDE and was able to build successfully. I was also able to attach the debugger to cAlgo.exe process. I've verified that the control goes to OnStart method and gets executed fine by placing a breakpoint. However, SourceSeries value does not get initialized. It just always stays Null.
//#reference:..\..\..\..\Rsi.TradeLibrary\Rsi.TradeLibrary\bin\Debug\Rsi.TradeLibrary.dll
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC)]
public class RsiTradeBot : Rsi.TradeLibrary.SampleBot
{
protected override void OnStart()
{
// Put your initialization logic here
base.OnStart();
}
protected override void OnTick()
{
// Put your core logic here
base.OnTick();
}
protected override void OnStop()
{
// Put your deinitialization logic here
base.OnStop();
}
}
}
Am I missing something? Can somebody please help me figure this out so I can debug the code correctly?
Thanks.