But it seems that the indicator updates only each tick, not each second.
I used a seconds timer to update the Value[0] in the plot, like below.
Print(thetime) works fine, but the plot update doesn't.
lastTime = DateTime.Now;
myTimer = new System.Timers.Timer(1000);
myTimer.Elapsed += TimerEventProcessor;
myTimer.Enabled = true;
private void TimerEventProcessor(Object myObject, EventArgs myEventArgs) {
TriggerCustomEvent(SetPriceMarker, 0, null);
}
private void SetPriceMarker(object dummy) {
ChartControl.Dispatcher.InvokeAsync((Action)(() =>
{
int secs = (int)(DateTime.Now.Subtract(lastTime).TotalMinutes *60);
string info = string.Format("{0:0}:{1:00}", secs/60, secs%60);
Print(info); //works and prints every second
//but these don't do anything before a tick appears:
Draw.TextFixed(this, "WjaTimeInBar", info, TextPosition.TopRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.White, Brushes.White, 100);
UpdateBar();
}));
}
protected override void OnBarUpdate()
{
if (IsFirstTickOfBar || Calculate==Calculate.OnBarClose) {
lastTime = Time[0];
}
UpdateBar();
}
private void UpdateBar() {
if (State==State.Realtime) {
Value[0] = DateTime.Now.Subtract(lastTime).TotalMinutes;
} else if (State==State.Historical) {
if (CurrentBar>1 && Time[0].Day==Time[1].Day) {
Value[0] = Time[0].Subtract(Time[1]).TotalMinutes;
}
}
}

Comment