Get data valiable double type form the Indicator class
Get data valiable double type form the Indicator class
03 Jan 2017, 09:29
Dear Sir
I try get the valiablre double type from the Indicator class. But the data as get the Indicator class incorrect. I don't know, What is wrong. Please help me for this wrong.
///////////////////////////////// Indicator class
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class test_1 : Indicator
{
[Parameter("Data 1", DefaultValue = 0)]
public int Data1 { get; set; }
[Parameter("Data 2", DefaultValue = 0)]
public int Data2 { get; set; }
[Output("Result1")]
public double Result_1 { get; set; }
[Output("Result2")]
public double Result_2 { get; set; }
protected override void Initialize()
{
// Initialize and create nested indicators
// Data1 = 30;
// Data2 = 10;
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] = ...
Result_1 = Data1 + Data2;
Result_2 = Data1 - Data2;
}
}
}
////////////////////////////////// cBot Class
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ddd : Robot
{
[Parameter("Data 1", DefaultValue = 0)]
public int Data1 { get; set; }
[Parameter("Data 2", DefaultValue = 0)]
public int Data2 { get; set; }
test_1 test;
protected override void OnStart()
{
// Put your initialization logic here
test = Indicators.GetIndicator<test_1>(Data1, Data2);
}
protected override void OnTick()
{
// Put your core logic here
Print("Result_1 ={0}", test.Result_1);
Print("Result_2 ={0}", test.Result_2);
Stop();
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
//////////////////////////////////
Replies
chkmitnb
03 Jan 2017, 09:30
( Updated at: 21 Dec 2023, 09:20 )
RE:
chkmitnb said:
Dear Sir
I try get the valiablre double type from the Indicator class. But the data as get the Indicator class incorrect. I don't know, What is wrong. Please help me for this wrong.
///////////////////////////////// Indicator class
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class test_1 : Indicator
{
[Parameter("Data 1", DefaultValue = 0)]
public int Data1 { get; set; }
[Parameter("Data 2", DefaultValue = 0)]
public int Data2 { get; set; }
[Output("Result1")]
public double Result_1 { get; set; }
[Output("Result2")]
public double Result_2 { get; set; }
protected override void Initialize()
{
// Initialize and create nested indicators
// Data1 = 30;
// Data2 = 10;
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] = ...
Result_1 = Data1 + Data2;
Result_2 = Data1 - Data2;
}
}
}////////////////////////////////// cBot Class
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ddd : Robot
{
[Parameter("Data 1", DefaultValue = 0)]
public int Data1 { get; set; }
[Parameter("Data 2", DefaultValue = 0)]
public int Data2 { get; set; }
test_1 test;
protected override void OnStart()
{
// Put your initialization logic here
test = Indicators.GetIndicator<test_1>(Data1, Data2);
}
protected override void OnTick()
{
// Put your core logic here
Print("Result_1 ={0}", test.Result_1);
Print("Result_2 ={0}", test.Result_2);
Stop();
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
//////////////////////////////////
@chkmitnb
... Deleted by UFO ...
chkmitnb
03 Jan 2017, 09:29
RE:
@chkmitnb