Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to display " ' " price notation

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

    How to display " ' " price notation

    Hello,

    Certain instruments like bonds display price on the margin as so 135'13. When I reference the price values programatically, 135'13 is returned as 135.40625. In some tracing that I'm doing, I'm printing these values to the output window.

    Is there a way to print 135'13 instead of 135.40625? Thank you!

    #2
    Hello MercuryScripter,

    Where x = the bond value (ex. 135.40625) you can get the raw bond value (ex. 135'13) using the following formula:

    Code:
    System.Math.Floor(x) + "'" + ((x - System.Math.Floor(x))*32).ToString("00")
    For a more advanced solution, please see this forum post: http://www.ninjatrader.com/support/f...ead.php?t=7122

    If we can be of further assistance, please let us know.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Hello Michael

      I followed the thread you pointed me to earlier and implemented the below code/function in my strategy. However, I get the following compilation error and don't understand how to resolve:

      'NinjaTrader.Strategy.TheAutomatedPitTrader.Format PriceMarker(float)': no suitable method found to override

      public override string FormatPriceMarker(double price)
      {
      double trunc = Math.Truncate(price);
      int fraction = Convert.ToInt32(320 * Math.Abs(price - trunc) - 0.0001); // rounding down for ZF and ZT
      string priceMarker = "";
      if (TickSize == 0.03125)
      {
      fraction = fraction/10;
      if (fraction < 10)
      priceMarker = trunc.ToString() + "'0" + fraction.ToString();
      else
      priceMarker = trunc.ToString() + "'" + fraction.ToString();
      }
      else if (TickSize == 0.015625 || TickSize == 0.0078125)
      {
      if (fraction < 10)
      priceMarker = trunc.ToString() + "'00" + fraction.ToString();
      else if (fraction < 100)
      priceMarker = trunc.ToString() + "'0" + fraction.ToString();
      else
      priceMarker = trunc.ToString() + "'" + fraction.ToString();
      }
      else
      priceMarker = price.ToString(Gui.Globals.GetTickFormatString(Tic kSize));
      return priceMarker;
      }

      Comment


        #4
        Hello MercuryScripter,

        You are receiving this error because NinjaScript strategies cannot override the FormatPriceMarker() method. The FormatPriceMarker() method is for indicators. To resolve this problem, simply adjust your method name and remove the override:

        Code:
        public string toFractionalPrice(double price)
        {
        double trunc = Math.Truncate(price);
        int fraction = Convert.ToInt32(320 * Math.Abs(price - trunc) - 0.0001); // rounding down for ZF and ZT
        string priceMarker = "";
        if (TickSize == 0.03125) 
        {
        fraction = fraction/10;
        if (fraction < 10)
        priceMarker = trunc.ToString() + "'0" + fraction.ToString();
        else 
        priceMarker = trunc.ToString() + "'" + fraction.ToString();
        }
        else if (TickSize == 0.015625 || TickSize == 0.0078125)
        {
        if (fraction < 10)
        priceMarker = trunc.ToString() + "'00" + fraction.ToString();
        else if (fraction < 100)
        priceMarker = trunc.ToString() + "'0" + fraction.ToString();
        else	
        priceMarker = trunc.ToString() + "'" + fraction.ToString();
        }
        else
        priceMarker = price.ToString(Gui.Globals.GetTickFormatString(TickSize));
        return priceMarker;
        }
        and then reference it in your code like this:

        Code:
        double price = 135.40625;
        string newprice = toFractionalPrice(price);
        The variable newprice would look like this: 135'13

        If we can be of further assistance, please let us know.
        Michael M.NinjaTrader Quality Assurance

        Comment

        Latest Posts

        Collapse

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