Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Customize Texts for custom barstype

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

    Customize Texts for custom barstype

    Hello, I have programmed a custom barstype. But the chart shows its name, not its values. How can I customize this text? (see attached image).

    I tried to override the ChartLabel, DisplayName and ToString methods but it did not work.

    Thanks in advance.
    Attached Files

    #2
    Hello cls71,

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to being of further assistance.

    Comment


      #3
      Hello,

      Thank you for your patience.

      If you look at the KagiBarTypes.cs in the NinjaScript editor, in the OnStateChange() method there is a switch/case statement that handles the naming based on the period of the chart.

      Like so:

      Code:
      switch (BarsPeriod.BaseBarsPeriodType)
      				{
      					case BarsPeriodType.Day		: Name = string.Format("{0} {1} Kagi{2}",		BarsPeriod.BaseBarsPeriodValue, BarsPeriod.BaseBarsPeriodValue == 1 ? Resource.GuiDaily		: Resource.GuiDay, BarsPeriod.MarketDataType != MarketDataType.Last		? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);	break;
      					case BarsPeriodType.Minute	: Name = string.Format("{0} Min Kagi{1}",		BarsPeriod.BaseBarsPeriodValue, BarsPeriod.MarketDataType != MarketDataType.Last ? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);																						break;
      					case BarsPeriodType.Month	: Name = string.Format("{0} {1} Kagi{2}",		BarsPeriod.BaseBarsPeriodValue, BarsPeriod.BaseBarsPeriodValue == 1 ? Resource.GuiMonthly	: Resource.GuiMonth, BarsPeriod.MarketDataType != MarketDataType.Last	? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);	break;
      					case BarsPeriodType.Second	: Name = string.Format("{0} {1} Kagi{2}",		BarsPeriod.BaseBarsPeriodValue, BarsPeriod.BaseBarsPeriodValue == 1 ? Resource.GuiSecond	: Resource.GuiSeconds, BarsPeriod.MarketDataType != MarketDataType.Last ? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);	break;
      					case BarsPeriodType.Tick	: Name = string.Format("{0} Tick Kagi{1}",		BarsPeriod.BaseBarsPeriodValue, BarsPeriod.MarketDataType != MarketDataType.Last ? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);																						break;
      					case BarsPeriodType.Volume	: Name = string.Format("{0} Volume Kagi{1}",	BarsPeriod.BaseBarsPeriodValue, BarsPeriod.MarketDataType != MarketDataType.Last ? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);																						break;
      					case BarsPeriodType.Week	: Name = string.Format("{0} {1} Kagi{2}",		BarsPeriod.BaseBarsPeriodValue, BarsPeriod.BaseBarsPeriodValue == 1 ? Resource.GuiWeekly	: Resource.GuiWeeks, BarsPeriod.MarketDataType != MarketDataType.Last	? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);	break;
      					case BarsPeriodType.Year	: Name = string.Format("{0} {1} Kagi{2}",		BarsPeriod.BaseBarsPeriodValue, BarsPeriod.BaseBarsPeriodValue == 1 ? Resource.GuiYearly	: Resource.GuiYears, BarsPeriod.MarketDataType != MarketDataType.Last	? string.Format(" - {0}", BarsPeriod.MarketDataType) : string.Empty);	break;
      				}
      Those conditions are ternary operators.

      I found this publicly available link on ternary operators:


      I would recommend doing something similar to this in your code.

      If there is anything else I may assist with please let me know.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X