Topics
Replies
jens_c_nielsen
18 Oct 2022, 01:06
RE: cBot is not picking up values from the indicator used in the cBot Hi,
Thanks heaps for your advice!
Is OnBar called at the start of a bar?
Have a good one!
@jens_c_nielsen
jens_c_nielsen
03 Oct 2022, 05:27
RE:
jens_c_nielsen said:
Hi
First - congratulations on this excellent platform! - just what I have been looking for!
My cBot draws some vertical lines and icons, which I would like to validate once a back-test is finished.
However once the back-testing finishes the cBot is stopped and the lines and icons are removed.
Is there a way to avoid the cBot getting stopped at the end of the back-test?
Thanks!
Please ignore this question - found the solution at cTDN Forum - ChartObjects drawn in visual backtesting disappear on test completion (ctrader.com)
Thanks!
@jens_c_nielsen
jens_c_nielsen
09 May 2023, 11:32 ( Updated at: 21 Dec 2023, 09:23 )
Thank you very much for your response!
I tried doing this but somehow the data only comes through as NaN in the cBot.
The indicator is like this:
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(TimeZone = TimeZones.UTC, IsOverlay = true, AccessRights = AccessRights.FullAccess)]
public class Sample_Indicator : Indicator
{
public IndicatorDataSeries DataToBeReadByIndicator { get; set; }
protected override void Initialize()
{
DataToBeReadByIndicator = CreateDataSeries();
}
public override void Calculate(int index)
{
DataToBeReadByIndicator[0] = 10.0;
DataToBeReadByIndicator[1] = 20.0;
DataToBeReadByIndicator[2] = 30.0;
Print("Sample_Indicator - values 0 from indicator: " + DataToBeReadByIndicator[0].ToString() ) ;
Print("Sample_Indicator - values 1 from indicator: " + DataToBeReadByIndicator[1].ToString() ) ;
Print("Sample_Indicator - values 2 from indicator: " + DataToBeReadByIndicator[2].ToString() ) ;
}
}
}
The cBot is like this:
using System;
using System.Linq;
using cAlgo;
using cAlgo.Indicators;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class cBot_Sample : Robot
{
private Sample_Indicator mySample_Indicator;
protected override void OnStart()
{
mySample_Indicator = Indicators.GetIndicator<Sample_Indicator>();
}
protected override void OnBar()
{
Print("cBot_Sample - values 0 from indicator: " + mySample_Indicator.DataToBeReadByIndicator[0].ToString() ) ;
Print("cBot_Sample - values 1 from indicator: " + mySample_Indicator.DataToBeReadByIndicator[1].ToString() ) ;
Print("cBot_Sample - values 2 from indicator: " + mySample_Indicator.DataToBeReadByIndicator[2].ToString() ) ;
}
protected override void OnStop()
{
}
}
}
When I run the indicator then the output is:
When I run the cBot the output is this:
Somehow I must be doing something wrong.
@jens_c_nielsen