Announcement

Collapse
No announcement yet.

script

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

  • script

    in need of help with a script. would like to have the color of the line turn green when its > previous bar & increasing / red when < previous bar & decreasing ( lines 58-59 ) can anyone help.

    Peter
    Attached Files

  • #2
    Hello Peter,

    You can find a code example of the routine you're looking for in this post by Alex. See Keltner(color).efs. I found this by doing a search on the phrase, color AND increas* AND decreas*. You can find a few more good posts on this topic by searching on color AND rising AND falling. If you have any trouble implementing this routine, post your formula here as an attachment rather than an image.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      thnx Jason

      Comment


      • #4
        Jason,

        tried changing the script but the color just remains green & doen't change to red when decreasing, any suggestions

        Peter
        Attached Files

        Comment


        • #5
          Hello Peter,

          There are a few corrections you need to make to your formula.

          1. You have initialized vRSX in both the global and local scope. Remove the "var vRSX;" that is inside main (local scope).

          2. You are using two variables for your studies that need to be initialized in the global scope (outside of main). Add the following just below var vRSX outside of main.

          PHP Code:
          var myJMAstudy null;
          var 
          myRSXstudy null
          3. The central problem that you have is a logic problem with your if statements that determine the color. vRSX >= vRSX-1 will always evaluate to true since vRSX - 1 will always be less than vRSX by a value of 1. You have in your code the global variable, prevRSX, that is storing the previous bar's value of vRSX. Try changing the logic in your if statements to the following.

          PHP Code:
          if (vRSX >= prevRSXsetBarFgColor(Color.green);
          if (
          vRSX prevRSXsetBarFgColor(Color.red); 
          Jason K.
          Project Manager
          eSignal - an Interactive Data company

          EFS KnowledgeBase
          JavaScript for EFS Video Series
          EFS Beginner Tutorial Series
          EFS Glossary
          Custom EFS Development Policy

          New User Orientation

          Comment


          • #6
            Jason,

            that works fine, also would like to know if it's possible to offset a Moving Ave by .5 (1/2) standard deviation to right or left. If this can be done what is the code to use.

            Peter

            Comment


            • #7
              Hello Peter,

              It is possible to apply an offset to a moving average. However, the offset value is represented by a bar index value (ie. -5 etc.). What is the data series you wanted to base the standard deviation on?
              Jason K.
              Project Manager
              eSignal - an Interactive Data company

              EFS KnowledgeBase
              JavaScript for EFS Video Series
              EFS Beginner Tutorial Series
              EFS Glossary
              Custom EFS Development Policy

              New User Orientation

              Comment


              • #8
                Jason

                I know that I can offset 1, 2, 3 .... or -1, -2, -3...., I tried using half (0.5) standard deviation & found that this value is not applicable or can this value be used by changing the script some how

                Peter

                Comment


                • #9
                  Hello Peter,

                  Offsets for shifting indicators left or right requires whole numbers. Advanced Charts do not support offsets by fractions of a bar. You'll have to round the number to the nearest whole number.
                  Jason K.
                  Project Manager
                  eSignal - an Interactive Data company

                  EFS KnowledgeBase
                  JavaScript for EFS Video Series
                  EFS Beginner Tutorial Series
                  EFS Glossary
                  Custom EFS Development Policy

                  New User Orientation

                  Comment


                  • #10
                    Jason,

                    thnx for the info.

                    Peter

                    Comment

                    Working...
                    X