Announcement

Collapse
No announcement yet.

Specific Decimal Places for Specific Symbols?

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

  • Specific Decimal Places for Specific Symbols?

    Hi,
    I use a Swing Pivot Study that calculates the Swing Waves based on Points Change.

    Is it possible to set the efs coding so that it will automatically adjust the Decimal Places of the Points Change to suit the new symbol that is entered?

    For Example:

    I have a chart displaying a non JPY Forex X-Rate that uses 4 Decimal Places (eg: EUR A0-FX), and my Swing Pivot Points Change is set to 0.0010.

    If I want to change the same chart to a JPY X-Rate which is using 2 Decimal places (or any other Symbol using 2 Decimal Places), I would want the Swing Pivot Points Change to be automatically altered to 0.10.

    The efs could potentially do this by:

    - filtering for Symbols containing JPY?
    - filtering for specific Symbols (eg: EURJPY A0-FX / ES #F)?
    - identifying the Decimal Places of the new Symbol, and if it is different from the previous Symbol, then automatically changing it?
    - any other means?

    I have about 8 charts running the Swing Pivot Study, and it would be so much easier if the adjustment could occur automatically, rather than me having to go through each chart and do it manually.


    Many thanks,
    Paul

  • #2
    Re: Specific Decimal Places for Specific Symbols?

    Paul
    Here is a relatively simple solution that does not involve filtering by symbol.
    Assume that the name of the FunctionParameter is "Percent" and that it is set to 0.0010 by default insert the following 3 lines of code at the top of your main function
    PHP Code:
    var formatPriceNumber(close(0));//convert the price to a string in the same format
    x.split(".");//split the string
    Percent x[1].length>2?Percent:Percent*100;//determine the length of the decimal portion and adjust Percent
    //debugPrintln(Percent); 
    This routine will determine if the symbol has two or more decimals and adjust the value of Percent accordingly.
    Hope this helps
    Alex


    Originally posted by TURLIES
    Hi,
    I use a Swing Pivot Study that calculates the Swing Waves based on Points Change.

    Is it possible to set the efs coding so that it will automatically adjust the Decimal Places of the Points Change to suit the new symbol that is entered?

    For Example:

    I have a chart displaying a non JPY Forex X-Rate that uses 4 Decimal Places (eg: EUR A0-FX), and my Swing Pivot Points Change is set to 0.0010.

    If I want to change the same chart to a JPY X-Rate which is using 2 Decimal places (or any other Symbol using 2 Decimal Places), I would want the Swing Pivot Points Change to be automatically altered to 0.10.

    The efs could potentially do this by:

    - filtering for Symbols containing JPY?
    - filtering for specific Symbols (eg: EURJPY A0-FX / ES #F)?
    - identifying the Decimal Places of the new Symbol, and if it is different from the previous Symbol, then automatically changing it?
    - any other means?

    I have about 8 charts running the Swing Pivot Study, and it would be so much easier if the adjustment could occur automatically, rather than me having to go through each chart and do it manually.


    Many thanks,
    Paul

    Comment


    • #3
      Hi Alexis,
      Thanks a lot for your reply.

      I tried the coding you suggested (and placed it a the top of the main function), but I could not get it to produce the desired result.

      The study I'm using is similar to the RealTimeSwings.efs posted by Jason in:

      eSignal Central Forums » EFS / API Development » EFS Library - Discussion Board » Misc » RealTimeSwings.efs

      Instead of using % Change for the Swings, I use Points Change.

      Another issue is that I use TDFX for my Forex rates (eg: EUR@TDFX A0-FX), and they display the JPY to 4-5 Decimal places (eg:100.18000).

      Paul

      Comment


      • #4
        Alex was correct. Try this..

        PHP Code:
        var formatPriceNumber(close(0));//convert the price to a string in the same format
        x.split(".");//split the string
        var nDecLength x[1].length
        With this code, the nDecLength variable should return the length of the fractional value of the current price. In other words, it should be 2, 3, 4 or 5 depending on which symbol you are loading your EFS on.

        Now, within your EFS script, you'll want to force the text drawing routines to format all prices to match the number of decimals indicated by nDecLength. Like this.

        PHP Code:
            "Time to sell @ "+close().toFixed(nDecLength); 
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Hi Brad,
          Thanks for your reply.

          When you say "Text Drawing Routines", are you refering to the Graphics (Text / Numbers) that are displayed at the Pivot Points? If so, then i can display these ok by using formatPriceNumber or .Fixed or a rounding function I have in the efs.

          It is the "PointMove" Function Parameter that I would like to have automatically changed to the specific Decimal Places of the new Symbol.

          If this can be done with the efs coding provided, then I don't have a clue how, and would appreciate any advice.

          Thanks,
          Paul

          Comment

          Working...
          X