Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Expose Properties of Indicator

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

    #16
    Originally posted by JMont1 View Post
    @NinjaTrader_Jesse, I am not trying to format to price. I am trying to format to a whole number like an int.

    so it would be some calculation that comes out to 20 or 23 or 25 but it prints depending on the instrument:


    23.0 for GC
    23.00 for ES
    23.000 for DX
    23.0000 for 6S
    23.000000 for 6J

    So I am trying to format it to just plain 23.

    Thanks for your prompt response.
    The solution that you have been given should do that. Have you tried using it at all?

    Otherwise, use a custom format string.

    refL https://docs.microsoft.com/en-us/dot...format-strings

    Comment


      #17
      Ihave tried this for hours now and cannot determine how to get an INT - which is the required format of the Strategy Builder to access the value to a whole number format based on the "double" that I seem to be getting advised to use.

      Even the custom format string is using a double.

      I have an INT that equals 23 and is being printed with the additional format of the price:

      private int rangeTicks = 0;


      rangeTicks = Convert.ToInt32((MAX(High, rangeBars)[0] - MIN(Low, rangeBars)[0]) / TickSize); // Get number of ticks in last rangeBars range

      Value[0] = rangeTicks;

      Prints in Market Analyzer column as:


      23.0 for GC
      23.00 for ES
      23.000 for DX
      23.0000 for 6S
      23.000000 for 6J

      I am certain that it is a simple line of code I am missing but cannot find the answer.

      Thank you for any further assistance.

      Comment


        #18
        Hello JMont1

        Yes in the analyzer, all values are displayed with the remainder like this because the Plot is a double. You would need to format the way the analyzer shows the data if you want to see it differently.

        The reply I had provided was in contrast to your comment that you already have an int value being assigned to the plot. If you dont, you would still see a double. To make sure you have an int, you can cast the value to an int which would still allow the strategy to read its value as well.

        Here is one test you could do:
        Code:
        protected override void OnBarUpdate()
        {
        	Value[0] = Close[0];
        } 
        	
        public override string FormatPriceMarker(double price)
        {
        	return price.ToString();
        }


        Now cast the value:

        Code:
        protected override void OnBarUpdate()
        {
        	Value[0] = (int)Close[0];
        } 
        		
        public override string FormatPriceMarker(double price)
        {
        	return price.ToString();
        }


        A strategy that calls this indicator and reads its plot would see the real value depending on the cast:

        2823.75
        2823.5
        2823.5
        or

        2823
        2822
        2823




        Please let me know if I may be of further assistance.

        Comment


          #19
          SInce I am not using price as the value I assumed I just needed to replace "price" with the "int" rangeTicks but I am still getting errors.

          I am going to give up and just accept the poor formatting.

          Thank you for trying.
          Last edited by JMont1; 08-16-2018, 07:43 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 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
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X