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 Brevo, Today, 01:45 AM
              0 responses
              3 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              3 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              238 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              384 views
              1 like
              Last Post Gavini
              by Gavini
               
              Started by oviejo, Today, 12:28 AM
              0 responses
              6 views
              0 likes
              Last Post oviejo
              by oviejo
               
              Working...
              X