Create a Timer In indicator
Created at 09 Apr 2020, 14:50
Create a Timer In indicator
09 Apr 2020, 14:50
Hello, I have tried to make a stopwatch independent of the ticks using the "Task" or "System.Threading.Timer" instruction in the Initialize function of an indicator. I have classified the variable that refers to the Task or thread as "static".
Both methods do not last. They stop after a few minutes.
How can I make a reliable counter inside an indicator without relying on ticks?
Regards.
public static System.Threading.Timer aTimer;
public static Task task = null;
bool Finished = false;
protected override void Initialize()
{
aTimer = new System.Threading.Timer(TimerCallback2, null, 1000, 50);
task = new Task(() =>
{
while (!this.Finished)
{
this.TimerCallback(null);
System.Threading.Thread.Sleep(10);
}
});
task.Start();
}
firemyst
28 May 2020, 15:49
RE:
bienve.pf said:
Why not just use a StopWatch object? The only timer I think you can reliably use is the built in timer within the cAlgo API.
@firemyst