Problem: Retrieve the updated value.
Created at 02 Dec 2024, 15:58
Problem: Retrieve the updated value.
02 Dec 2024, 15:58
I am having trouble retrieving the latest updated value (NetProfit of position) for my bot. I have the following code:
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using System.Collections.Generic;
using System.Threading;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None, AddIndicators = true)]
public class Check : Robot
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
List<Position> ps;
protected override void OnStart()
{
ps = new List<Position>();
foreach(var p in Positions)
{
ps.Add(p);
}
}
protected override void OnTick()
{
string log = "";
foreach (var p in ps)
{
log+= $"{p.SymbolName}:{p.NetProfit} ";
}
Print(log);
Thread.Sleep(2000); // As a replacement for algorithmic complexity, the runtime complexity can take up to 2 seconds for analysis.
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}
The problem is that the longer it runs, the more the position value I receive deviates over time!
How can I fix this error?
PanagiotisCharalampous
03 Dec 2024, 07:37
Hi there,
What is your account's currency? The net profit printed in the log is in your account's currency while the screenshot shows the net profit in $
Best regards,
Panagiotis
@PanagiotisCharalampous