Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:


      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 Aviram Y, Today, 05:29 AM
      0 responses
      2 views
      0 likes
      Last Post Aviram Y  
      Started by quantismo, 04-17-2024, 05:13 PM
      3 responses
      25 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by ScottWalsh, 04-16-2024, 04:29 PM
      7 responses
      34 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cls71, Today, 04:45 AM
      0 responses
      6 views
      0 likes
      Last Post cls71
      by cls71
       
      Started by mjairg, 07-20-2023, 11:57 PM
      3 responses
      217 views
      1 like
      Last Post PaulMohn  
      Working...
      X