Announcement

Collapse
No announcement yet.

MA with 2 dezimals in Bonds

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

  • MA with 2 dezimals in Bonds

    Hi, I need help. If I´m right thats the code for the simple MA.
    Is there a possibility to change it so that its shown in 2 decimals also in the bonds?



    Thanks in advance

    Martin
    Attached Files

  • #2
    Martin
    If you are referring to the US Bonds it will display fractions (expressed in 32nds) and not decimals as it uses the same format of the price chart.
    Alex

    Comment


    • #3
      Yes Alex, I refer to US Bonds. So its impossible to get the MA in decimals if the price is in fractions?

      Martin

      Comment


      • #4
        Martin
        The plot (ie what the formula returns to the chart) will be displayed only in the format of the symbol hence in the case of the US Bonds points and 32nds of a point.
        Having said that you can modify the formula to also return the value of the average converted to a string which will at the same time convert the fractions into decimals. While an efs will not plot a string it will return its values to the Cursor Window.
        The easiest way to do this is to use the .toFixed() method which will allow you to also define the number of decimals displayed. To implement this modification replace the following line of code in the efs you posted



        with the following block of code. Comments alongside the code explain the various steps



        The script will now return an array of two elements ie myAvg and myModAvg. In the Cursor Window in fact you will now see two labels one of which will display the value of the average in points and 32nds of a point and the other in points and 2 decimals (as per the parameter used in the .toFixed() method)
        If you only want to see one of these labels in the Cursor Window then add a setShowCursorLabel() statement in the preMain() function to hide the other one. For example assuming you want to hide the label that displays points and fractions you would add the following to preMain()



        The Cursor Window will now display only the label with the value expressed in points and decimals. Note that this functionality is available starting with eSignal 10.0.
        For the descriptions of the .toFiixed() and setShowCursorLabel() method and function and their required syntax see the linked articles in the EFS KnowledgeBase
        Hope this helps
        Alex

        Comment


        • #5
          Thank you Alex. I really appreciate you help
          Martin

          Comment


          • #6
            Martin
            You are most welcome
            Alex

            Comment

            Working...
            X