Announcement

Collapse
No announcement yet.

need to add R3 S3 support

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

  • need to add R3 S3 support

    I was able to find the below .efs study and it works just great.

    Could someone help me add R3 and S3.

    Bruce

    P.S. I don't know where I found this and don't know who originally created it but you have my apprecation


    ==========

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Prior Day");
    setCursorLabelName("R2", 0);
    setCursorLabelName("R1", 1);
    setCursorLabelName("PP", 2);
    setCursorLabelName("S1", 3);
    setCursorLabelName("S2", 4);
    setCursorLabelName("H", 5);
    setCursorLabelName("C", 6);
    setCursorLabelName("L", 7);
    //setComputeOnClose(true);

    // R2
    setDefaultBarStyle(PS_DASH, 0);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarThickness(2, 0);

    // R1
    setDefaultBarStyle(PS_DASH, 1);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarThickness(1, 1);

    // Pivot Point
    setDefaultBarStyle(PS_DASH, 2);
    setDefaultBarFgColor(Color.blue, 2);
    setDefaultBarThickness(1, 2);

    // S1
    setDefaultBarStyle(PS_DASH, 3);
    setDefaultBarFgColor(Color.green, 3);
    setDefaultBarThickness(1, 3);

    // S2
    setDefaultBarStyle(PS_DASH, 4);
    setDefaultBarFgColor(Color.green, 4);
    setDefaultBarThickness(2, 4);

    // Previous Day's High
    setDefaultBarStyle(PS_SOLID, 5);
    setDefaultBarFgColor(Color.green, 5);
    setDefaultBarThickness(1, 5);

    // Previous Day's Close
    setDefaultBarStyle(PS_SOLID, 6);
    setDefaultBarFgColor(Color.grey, 6);
    setDefaultBarThickness(1, 6);

    // Previous Day's Low
    setDefaultBarStyle(PS_SOLID, 7);
    setDefaultBarFgColor(Color.red, 7);
    setDefaultBarThickness(1, 7);
    }

    // globals
    var vOutputArray = null;
    var vLastSeenDay = null;
    var vInterval = null;
    var vSymbol = null;

    function main() {

    // initialize upon first loading formula
    if(getBarState() == BARSTATE_ALLBARS) {

    vInterval = getInterval();
    vSymbol = getSymbol().toUpperCase();

    // for RTH, eg, to convert, ES Z2 to ES Z2=2
    var rootSymbol = vSymbol.substring(0,3);
    if (rootSymbol == "ES " || rootSymbol == "NQ ")
    if ( vSymbol.indexOf("=2") == -1 )
    vSymbol += "=2";

    vSymbol += ",D";
    return null;
    }

    // return null if not an intraday chart
    if(vInterval == null || vInterval == "D" ||
    vInterval == "W" || vInterval == "M" || vInterval == "T")
    return null;

    // if first bar in new day, get and save yesterday's data
    var vThisday = null;
    if (vLastSeenDay != (vThisDay = getDay()) ) {

    var vTime = getValue("Time");
    if(vTime != null) {
    var vYDay = getPreviousTradingDay(vTime,vSymbol);
    if(vYDay != null) {
    var vIndex = getFirstBarIndexOfDay(vYDay,vSymbol);
    if(vIndex != null) {
    var ydayH = getValueAbsolute("High", vIndex,
    vSymbol);
    var ydayL = getValueAbsolute("Low", vIndex,
    vSymbol);
    var ydayC = getValueAbsolute("Close", vIndex,
    vSymbol);
    var ydayP = (ydayH + ydayL + ydayC) / 3;
    var ydayR1 = 2 * ydayP - ydayL;
    var ydayS1 = 2 * ydayP - ydayH;
    var ydayR2 = (ydayP - ydayS1) + ydayR1;
    var ydayS2 = ydayP - (ydayR1 - ydayS1);
    vOutputArray = new Array
    (ydayR2,ydayR1,ydayP,ydayS1,ydayS2,
    ydayH,ydayC,ydayL);

    vLastSeenDay = vThisDay;
    return vOutputArray;
    }
    }
    return null;
    }
    }
    // else just return the saved data
    else
    return vOutputArray;

    }

  • #2
    I've added R3/S3, R4/S4, and R5/S5. All the pivot lines are solid. The H/L/C lines are dashed. Good formula to have today; ES/NQ got down to S4. MSFT got down to S3.
    Attached Files

    Comment


    • #3
      Thanks

      Thanks for the support EFS.

      It works great but I was wondering how I can have the R's and S's displayed on my Data Window in the following order:

      New Current

      R5 R2
      R4 R1
      R3 PP
      R2 S1
      R1 S2
      PP H
      S1 C
      S2 L
      S3 R3
      S4 S3
      S5 R4
      H S4
      C R5
      L S5

      Its more of a visual thing than anything else.

      Thanks again.

      Bruce

      P.S. I had to add:

      setCursorLabelName("R5", 12);
      setCursorLabelName("S5", 13);

      I think they were left off.

      Comment


      • #4
        Bruce
        You change the order in which they appear in the Cursor Window in this section of the formula

        vOutputArray = new Array
        (ydayR2,ydayR1,ydayP,ydayS1,ydayS2,
        ydayH,ydayC,ydayL,ydayR3,ydayS3,ydayR4,ydayS4,yday R5,ydayS5);

        The settings for Color, Line Thickenss, Label Name etc can be found in preMain()
        All the settings ,0) in preMain() correspond to your first return in the vOutputArray, the setting ,1) to the second one, etc.
        Alex

        Comment


        • #5
          Alex:

          I tried what you suggested but the Cursor display stayed the same but the plotting did change.

          Any more sugestions.

          Bruce

          P.S. its works just fine all I would like it to do is to display in the cursor window based upon the levels.

          Comment


          • #6
            Bruce
            Probably you did not rearrange the statements in preMain() besides the ones in the vOutputArray
            Anyhow here it is with everything in its place. Up to you to fix the colors.
            Alex
            Attached Files

            Comment


            • #7
              Alex:

              Its perfect.

              I was able to change the colors, the dots, the dashes, etc.

              I truly appreciate your help....thanks again.

              Bruce

              Comment


              • #8
                Alex

                Alex:

                I noticed if I refresh my data the yC changes (to the current close).....is there any way to have it not do this.

                Bruce

                P.S. the yH and yL are OK.

                Comment


                • #9
                  Bruce
                  I am not seeing that happen. The screenshot below was taken right after a reload
                  Alex


                  Comment


                  • #10
                    Alex:

                    Could you send me the .EFS again.

                    It seems mine is a bit different than your.

                    Bruce

                    P.S. I downloaded the last one you sent me again and there is no R5 nor S5.

                    Comment


                    • #11
                      Alex:

                      BTW: I do use 24 hour data.

                      Bruce

                      Comment


                      • #12
                        Bruce
                        The efs I used to create the image is the one last posted in this thread. I just downloaded it a few minutes ago to crosscheck your problem.
                        The only difference is that I painted the yC in black to make it more visible.
                        Alex

                        Comment


                        • #13
                          I just downloaded it again and same problem (if I refresh the data the yC changes to the current close).

                          I'll reboot and see if its the software.

                          Thanks.

                          Bruce

                          Comment


                          • #14
                            Alex:

                            I rebooted and that solved the problem.

                            Thanks so much for all your help.

                            Bruce

                            Comment

                            Working...
                            X