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 sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,233 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      1 view
      0 likes
      Last Post thread
      by thread
       
      Started by jclose, Yesterday, 09:37 PM
      0 responses
      6 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,414 views
      0 likes
      Last Post Traderontheroad  
      Started by firefoxforum12, Yesterday, 08:53 PM
      0 responses
      11 views
      0 likes
      Last Post firefoxforum12  
      Working...
      X