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

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.
        JesseNinjaTrader Customer Service

        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 sidlercom80, 10-28-2023, 08:49 AM
          166 responses
          2,234 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