Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Decimals in a price maker

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

    Decimals in a price maker

    Hello,

    I am looking for a method to put correct decimals in a price maker.

    Usually I use this function into my indicators:

    public override string FormatPriceMarker(double price)
    {
    return price.ToString("N4");
    }

    In a chart how 6E (1.3716) or 6J (0.009762 with ToString("N6") of course)
    it works perfectly.

    But if I try to use it in Soyabeans future, I obtain an error. The price 1474.25 turns 1.474.25... how can I leave just the second decimal?

    #2
    Hi merzo,

    I think your actually looking at a comma that is separating the thousands place.

    You can remove the comma with .Replace.

    return price.ToString("N4").Replace(",", "");
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi,
      thanks for your help.

      Unfortunately, it works on all decimals:

      Original price: 1474.25

      Old script: 1.474.25 - return price.ToString("N2")

      Your script: 147425 - return price.ToString("N2").Replace(".","");

      Comment


        #4
        Hello merzo,

        This is not the code from my previous post #2.

        My code uses a comma in the replace. Your code uses a period.

        Please copy and paste the code I have posted in post #2.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks ChelseaB,

          copy and past now:

          return price.ToString("N4").Replace(",", "");

          result is: 1.474.2500

          Comment


            #6
            Hi merzo,

            This is not what I am getting on my end.

            May I have an export of your script?

            To export your script do the following:

            1. Click File -> Utilities -> Export NinjaScript
            2. Enter a unique name for the file in the value for 'File name:'
            3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
            4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message

            By default your exported file will be in the following location:

            * (My) Documents/NinjaTrader 7/bin/Custom/ExportNinjaScript/<export_file_name.zip>


            Below is a link to the help guide on Exporting NinjaScripts.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello,
              thanks for your reply.

              I solved it my problem just now.
              Best

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by RaygunWizzle, Today, 09:30 AM
              2 responses
              12 views
              0 likes
              Last Post bltdavid  
              Started by Ashkam, Today, 09:28 AM
              0 responses
              9 views
              0 likes
              Last Post Ashkam
              by Ashkam
               
              Started by gbourque, Today, 08:20 AM
              1 response
              13 views
              0 likes
              Last Post gbourque  
              Started by carnitron, 04-27-2024, 08:42 PM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by WHICKED, 04-26-2024, 12:56 PM
              3 responses
              63 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Working...
              X