Why won't this code print any value other than zero for the indicator?
Why won't this code print any value other than zero for the indicator?
05 May 2019, 16:46
Hi everyone:
See screen capture and code below. Despite hard-coding the public property being set to 4 by the bot, the indicator never displays a value other than zero.
Why? What am I missing?
It should pick up the value of the public property that is set by the bot, and then set the IndicatorDataSeries "UpwardBuy" to 4.
Thank you :-)

Indicator code:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Collections.Generic;
namespace cAlgo
{
[Levels(2, 1, 0)]
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ConditionsOfEntry : Indicator
{
[Output("UpwardSell", LineStyle = LineStyle.Solid, PlotType = PlotType.Line, LineColor = "Red")]
public IndicatorDataSeries UpwardSell { get; set; }
[Output("UpwardNeutral", LineStyle = LineStyle.Solid, PlotType = PlotType.Line, LineColor = "Yellow")]
public IndicatorDataSeries UpwardNeutral { get; set; }
[Output("UpwardBuy", LineStyle = LineStyle.Solid, PlotType = PlotType.Line, LineColor = "Lime")]
public IndicatorDataSeries UpwardBuy { get; set; }
public int UpwardCount { get; set; }
//private const int UpwardMax = 5;
public override void Calculate(int index)
{
//if (UpwardCount >= UpwardMax)
UpwardBuy[index] = UpwardCount;
//else if (UpwardCount > Math.Round(UpwardMax / 2.0, MidpointRounding.AwayFromZero))
// UpwardNeutral[index] = UpwardCount;
//else
// UpwardSell[index] = UpwardCount;
}
}
}
Bot code:
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, AccessRights = AccessRights.None)]
public class TestBot : Robot
{
private string _positionLabel = String.Empty;
private MarketSeries _marketSeries;
private ConditionsOfEntry _c = new ConditionsOfEntry();
protected override void OnStart()
{
_marketSeries = MarketData.GetSeries(Symbol, MarketSeries.TimeFrame);
DataSeries series = _marketSeries.Close;
_positionLabel = (MarketSeries.TimeFrame) + " " + Symbol.Code + " Test Bot";
_c = Indicators.GetIndicator<ConditionsOfEntry>();
}
protected override void OnTick()
{
if (SumOfLongEntryConditions() >= 5)
Print("Hello");
else
Print("Oh no!");
}
private int SumOfLongEntryConditions()
{
int _sumOfLongEntryConditions = 4;
Print("_sumOfLongEntryConditions {0}", _sumOfLongEntryConditions);
_c.UpwardCount = _sumOfLongEntryConditions; //set to 4
return _sumOfLongEntryConditions;
}
}
}
Replies
ctid+customer-395444
06 May 2019, 16:32
RE:
Panagiotis Charalampous said:
Hi FireMyst,
I am not sure what do you expect to happen here. Indicators referenced by cBots are not displayed on the charts.
Best Regards,
Panagiotis
What I was hoping to achieve, is to have some values calculated in the bot based on all the indicators on the current tick, and then display those calculated values on a separate chart (hence the "IsOverlay = false" because those calculated values would be anywhere from -10...0...10 (kind of like an oscillator).
But from what you're telling me, I'd have to create another indicator that:
1) references all the other indicators I want used in the calculations
2) incorporate the bot's calculation logic
and add it to the chart as a separate indicator?
There's currently no way then to draw objects on a chart that's not the main chart? Or is there?
Thank you.
@ctid+customer-395444
PanagiotisCharalampous
06 May 2019, 16:39
Hi FireMyst,
1) references all the other indicators I want used in the calculations
2) incorporate the bot's calculation logic
indeed this is the correct approach
There's currently no way then to draw objects on a chart that's not the main chart? Or is there?
There is but you need to manually add the area. See below an example
Chart.IndicatorAreas[0].DrawText("Test", "Test", Server.Time, 50, Color.Red);
Best Regards,
Panagiotis
@PanagiotisCharalampous
ctid+customer-395444
06 May 2019, 16:47
RE:
Panagiotis Charalampous said:
Hi FireMyst,
1) references all the other indicators I want used in the calculations
2) incorporate the bot's calculation logic
indeed this is the correct approach
There's currently no way then to draw objects on a chart that's not the main chart? Or is there?
There is but you need to manually add the area. See below an example
Chart.IndicatorAreas[0].DrawText("Test", "Test", Server.Time, 50, Color.Red);Best Regards,
Panagiotis
Perfect! Thanks yet again!
@ctid+customer-395444

PanagiotisCharalampous
06 May 2019, 12:37
Hi FireMyst,
I am not sure what do you expect to happen here. Indicators referenced by cBots are not displayed on the charts.
Best Regards,
Panagiotis
@PanagiotisCharalampous