Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Showing time remaining to the right

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Showing time remaining to the right

    Hi,
    I created custom copy of BarTimer indicator where I want to show time remaining not on the current bar but to the right, like on the attached image. How can I do it?


    Draw.Text(this, "NinjaScriptInfo1", true, timeLeft, Bars.GetTime(CurrentBar), Bars.GetClose(Bars.Count-1), 0, Brushes.Blue, ChartControl.Properties.LabelFont, System.Windows.TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0);


    if (connected)
    {
    if (SessionIterator.IsInSession(Now, false, true))
    {
    if (hasRealtimeData)
    {
    TimeSpan barTimeLeft = Bars.GetTime(Bars.Count - 1).Subtract(Now);

    timeLeft = (barTimeLeft.Ticks < 0
    ? "00:00:00"
    : barTimeLeft.Hours.ToString("00") + ":" + barTimeLeft.Minutes.ToString("00") + ":" + barTimeLeft.Seconds.ToString("00"));

    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.BarTimerTimeRemaining + timeLeft, TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Text(this, "NinjaScriptInfo1", true, timeLeft, Bars.GetTime(CurrentBar), Bars.GetClose(Bars.Count-1), 0, Brushes.Blue, ChartControl.Properties.LabelFont, System.Windows.TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0);
    }
    else
    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.BarTimerWaitingOnDataE rror, TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);
    }
    else
    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.BarTimerSessionTimeErr or, TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);​

    Click image for larger version

Name:	image.png
Views:	168
Size:	9.2 KB
ID:	1310692

    #2
    Hello tkaboris,

    You would need to change from using Draw.TextFixed to Draw.Text and then specify a negative bars ago as its anchor point. While that is unsupported it should work to push the text past the current bar. There is no way to make the chart automatically move to include that but you can manually scroll the chart to see it. If you wanted to accomplish that in a way that does not require manually scrolling you could use OnRender to display text at specific X and Y coordinates and then use the charts right side margin property in its property menu to push the bars back past the text.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    590 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    342 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    555 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X