What the hack is going on....
What the hack is going on....
24 Feb 2015, 20:05
Hi,
watch this:
Using a smal testindicator for displying the problem I don't understand:
If I'M using the indicator only on a chart it display the rigth values related to it's calculation.
Referencing anf using the same indicator within a robot I always get the same result. What is going wrong, where is the mistake?
I don't understand this....maybe I'm not alone ;-)
********************** indicator
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TestIndicator : Indicator
{
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
protected override void Initialize()
{
// Initialize and create nested indicators
//Result = CreateDataSeries();
}
public override void Calculate(int index)
{
if (MarketSeries.Open[index] >= MarketSeries.Close[index])
{
Result[index] = -1.0;
}
else if (MarketSeries.Open[index] < MarketSeries.Close[index])
{
Result[index] = 1.0;
}
else
{
Result[index] = 0;
}
ChartObjects.DrawText("test", string.Format("Value: {0}", Result[index - 1]), StaticPosition.TopRight, Colors.Red);
}
}
}
********************* robot
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TestBot : Robot
{
private TestIndicator _test1;
protected override void OnStart()
{
_test1 = Indicators.GetIndicator<TestIndicator>;
}
protected override void OnBar()
{
Print("TestValue {0}", _test1.Result.LastValue);
}
}
}
Replies
Spotware
27 Feb 2015, 14:34
Spotware doesn't provide cBot development support. We can recommend you to contact one of our Partners or post a job in Development Jobs section.
@Spotware
hotcoffee
04 Mar 2015, 14:03
RE:
Spotware said:
Spotware doesn't provide cBot development support. We can recommend you to contact one of our Partners or post a job in Development Jobs section.
Perhaps a relevant question that you can answer. Do all indicators (custom or otherwise) change value on each tick, despite not being accessed, used or otherwise referenced in OnTick()? My indicators work fine when placed on a sheet, but the robot version of them sees different value. My searching of the forum suggests that indicators change on the tick. My question then is does customIndicator.Last(1) refer to the previous tick rather then the last bar when called in OnBar(). Similiar question with Maximum and Minimum functions. If I had my DataSeries Source set to 1 minute bars, would Source.Maximum(10); refer to the last 10 bars, or last 10 ticks?
@hotcoffee
Spotware
04 Mar 2015, 17:58
Perhaps a relevant question that you can answer. Do all indicators (custom or otherwise) change value on each tick, despite not being accessed, used or otherwise referenced in OnTick()? My indicators work fine when placed on a sheet, but the robot version of them sees different value.
Indicators in cBots are lazy, they are calculated when cBots gets their values.
My question then is does customIndicator.Last(1) refer to the previous tick rather then the last bar when called in OnBar()
Last(index) method takes a value by index from the end of data series. It is not about ticks.
@Spotware
cicondo
25 Feb 2015, 14:34
RE: where is the support
It looks like the support exists only for repeating problems.. :-)
@cicondo