Announcement

Collapse
No announcement yet.

Yen / Reconciling coding of 2 decimal places -vs- 4 decimal places

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

  • Yen / Reconciling coding of 2 decimal places -vs- 4 decimal places

    I have been unable to think of the answer to a problem I have with a Study I want to use for all currencies. I've used a combination of the Wizard and manual intervention and the code executes without errors but not as I want it to. I'm not a coder but have used/created several of the Studies including BBs, Envelopes, Expired, AuthorisedUsers, etc so have developed some logical experience.

    Basically, I want to raise an Alert:
    if Price Action is within 3 pips of an envelope but only when BB is inside the Envelope.
    I have successfully written this standalone Study raising an Alert for the 4 decimal currencies (e.g. GBP i.e. use * 10000 in calculations)
    and a standalone Study for the 2 decimal currencies (e.g. Yen i.e. * 100)

    - BUT HAVE NOT been able to think/find the solution to combining the two i.e. the 2 decimals Alert always overrides the 4 decimal currency Alert.


    Is there something obvious I'm missing or is there some sort of code which states the equivalent of:
    "If any of these currency symbols are used (e.g. JPY, etc), then use the 2 decimal code & Alert"?


    I can't help but think that other users may have encountered similar issue but been unable to find relevant posting on the subject.

    I've done various other searches but none of the mathamatical/fixed etc functions appear to help. Any assistance would be appreciated.


  • #2
    The return value from this function should give you the correct answer:

    PHP Code:
    function getDecimalPlaces()
    {
      var 
    dec 0;
      var 
    strs formatPriceNumber(close(0)).split(".");
      if (
    strs.length == 2)
      {
        
    dec strs[1].length;
      }
      return 
    dec;

    Comment


    • #3
      Thank you

      Comment

      Working...
      X