• 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 sandman, Today, 05:47 AM
      0 responses
      2 views
      0 likes
      Last Post sandman
      by sandman
       
      Started by sidviciousX, Yesterday, 07:24 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by cls71, Today, 04:31 AM
      0 responses
      3 views
      0 likes
      Last Post cls71
      by cls71
       
      Started by KSTrader, Today, 12:45 AM
      0 responses
      4 views
      0 likes
      Last Post KSTrader  
      Started by Lklforex, Yesterday, 08:48 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Working...
      X