• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    Chris L.NinjaTrader Customer Service

    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:
      http://www.dnawebagency.com/ternary-operator/

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

      If there is anything else I may assist with please let me know.
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by learningnt, Today, 08:47 AM
      0 responses
      16 views
      0 likes
      Last Post learningnt  
      Started by alikair, 12-08-2016, 07:28 AM
      4 responses
      1,555 views
      0 likes
      Last Post vjsworld  
      Started by Pooh123, Today, 05:06 AM
      0 responses
      4 views
      0 likes
      Last Post Pooh123
      by Pooh123
       
      Started by joemiller, Today, 03:32 AM
      0 responses
      2 views
      0 likes
      Last Post joemiller  
      Started by joemiller, Today, 03:30 AM
      0 responses
      0 views
      0 likes
      Last Post joemiller  
      Working...
      X