Hi guys - do you know if its possible to write an indicator that draws a line X amount of time set by the user?
You can consider using OnTimer for this.
In the indicator class I have been trying to use the Timer (from Algo.API) but without sucess.
So, I used the System.Timers class and it work...
Put the namespace as the example bellow: (NOTE: put it in this order... because if you reference the System.Timers afterthe cAlgo.API a ambiguos error is showed.)
using System.Timers; // This is the Timer class from System namespace
After this you need create the Class for it...
Declare this class inside your Public Class Indicator
private static System.Timers.Timer aTimer;
So now... you need to initialize the timer and set the interval.
In the Initialize function do it:
protected override void Initialize()
aTimer = new System.Timers.Timer(1000); // 1000 is the time in milliseconds
aTimer.Elapsed += OnTimedEvent; // ---------->> Attention here!!
aTimer.AutoReset = true;
aTimer.Enabled = true;
look into the code a line aTimer.Elapsed += OnTimedEvent. This is the function that will be called when the Timer elapsed happen.
So you need to created this function.... so try it:
private void OnTimedEvent(Object source, ElapsedEventArgs e)
// Put here your code that will be executed in timer elapsed.
So... I hope this helps