Announcement

Collapse
No announcement yet.

Dynamic Monthly Pivot Points

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

  • Dynamic Monthly Pivot Points

    Hello,

    I would like to modify the following efs called "Monthly Pivot Points" (by Alex Montenegro) in a way that it calculates and plots these monthly levels based on the following datapoints:
    Highest High of the past 3 months
    LowestLow of the past 3 months
    and the current months close.

    And got no idea how to do that.......


    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Monthly Pivot Points");
    setCursorLabelName("PP-R2", 0);
    setCursorLabelName("PP-R1", 1);
    setCursorLabelName("PP", 2);
    setCursorLabelName("PP-S1", 3);
    setCursorLabelName("PP-S2", 4);
    // R2
    setDefaultBarStyle(PS_DASH, 0);
    setDefaultBarFgColor(Color.RGB(255,0,0), 0);
    setDefaultBarThickness(2, 0);
    // R1
    setDefaultBarStyle(PS_DOT, 1);
    setDefaultBarFgColor(Color.RGB(0,0,255), 1);
    setDefaultBarThickness(1, 1);
    // Pivot Point
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarFgColor(Color.RGB(0,0,0), 2);
    setDefaultBarThickness(1, 2);
    // S1
    setDefaultBarStyle(PS_DOT, 3);
    setDefaultBarFgColor(Color.RGB(0,0,255), 3);
    setDefaultBarThickness(1, 3);
    // S2
    setDefaultBarStyle(PS_DASH, 4);
    setDefaultBarFgColor(Color.RGB(255,0,0), 4);
    setDefaultBarThickness(2, 4);
    }

    var bInit = false;
    var xHigh = null;
    var xLow = null;
    var xClose = null;
    var vPP = null;
    var vR1 = null;
    var vS1 = null;
    var vR2 = null;
    var vS2 = null;

    function main() {

    if(bInit == false){
    xHigh = high(inv("M"));
    xLow = low(inv("M"));
    xClose = close(inv("M"));
    bInit = true;
    }

    var vHigh = xHigh.getValue(-1);
    var vLow = xLow.getValue(-1);
    var vClose = xClose.getValue(-1);
    if(vHigh == null || vLow == null || vClose == null)
    return;

    vPP = (vHigh+vLow+vClose)/3;
    vR1 = 2*vPP-vLow;
    vS1 = 2*vPP-vHigh;
    vR2 = (vPP-vS1)+vR1;
    vS2 = vPP-(vR1-vS1);

    return new Array(vR2, vR1, vPP, vS1, vS2);
    }

    Anybody can help?

    Thanks

  • #2
    Can nobody help?

    Comment


    • #3
      Still need help on my Pivot.efs

      I am trying to create this Pivots using the 3-month High, Low. Close. Used a Call-efs-function, have no idea if I am on the right track............just can't get it to work
      here is the file:


      function preMain() {

      setPriceStudy(true);
      setStudyTitle("Dynamic Pivots Monthly");
      setCursorLabelName("R2", 0);
      setCursorLabelName("R1", 1);
      setCursorLabelName("PP", 2);
      setCursorLabelName("S1", 3);
      setCursorLabelName("S2", 4);
      setDefaultBarFgColor(Color.RGB(255,255,0), 0);
      setDefaultBarFgColor(Color.RGB(255,255,0), 1);
      setDefaultBarFgColor(Color.RGB(255,255,0), 2);
      setDefaultBarFgColor(Color.RGB(255,255,0), 3);
      setDefaultBarFgColor(Color.RGB(255,255,0), 4);
      setDefaultBarThickness(2, 0);
      setDefaultBarThickness(2, 1);
      setDefaultBarThickness(2, 2);
      setDefaultBarThickness(2, 3);
      setDefaultBarThickness(2, 4);
      setPlotType(PLOTTYPE_DOT,0);
      setPlotType(PLOTTYPE_DOT,1);
      setPlotType(PLOTTYPE_FLATLINES,2);
      setPlotType(PLOTTYPE_DOT,3);
      setPlotType(PLOTTYPE_DOT,4);


      }

      var vOpen = null;
      var vOpen1 = null;
      var vHigh = null;
      var vHigh1 = null;
      var vLow = null;
      var vLow1 = null;
      var vClose1 = null;

      var vPP = null;
      var vR1 = null;
      var vR2 = null;
      var vS1 = null;
      var vS2 = null;



      function main() {
      var vTime = getValue("time");//create date object using bar time
      var vData = callFunction("/OHLC/getPrevMonthsOHLC.efs", "Open", "High", "Low", "Close", -2, 2);
      if (vData == null) return;
      return vData;



      if (close(-1)==null)
      return;

      if(getBarState()==BARSTATE_NEWBAR&&getMonth()!=get Month(-1)) {
      vHigh1 = vHigh;
      vLow1 = vLow;
      vClose1 = call("/OHLC/getPrevMonthsOHLC.efs", "Close");//comment out this line if using alternate vClose1
      vHigh = high();
      vLow = low();
      }

      if (vHigh == null)
      vHigh = high();
      if (vLow == null)
      vLow = low();


      vHigh = Math.max(high(), vHigh);
      vLow = Math.min(low(), vLow);


      //alternate vClose1 if one wants to use the daily bar Close. NOTE that this will not work with Tick Replay
      //vClose1 = call("/OHLC/getPrevOHLC.efs", "Close");

      //for alternative Pivots that require today's Open use vOpen in the Pivot calculations


      vPP = (vHigh1 + vLow1 + vClose1) / 3;
      vR1 = 2 * vPP - vLow1;
      vR2 = vPP + vHigh1 - vLow1;
      vS1 = 2 * vPP - vHigh1;
      vS2 = vPP - vHigh1 + vLow1;


      if (vOpen1 == null || vLow1 == null || vHigh1 == null || vClose1 == null) {
      return;
      } else {
      return new Array(vR2,vR1,vPP,vS1,vS2);
      }
      }




      I would really appreciate your help

      THX

      Comment


      • #4
        I am using the below code to use Yesterdays close instead of last month close for Monthly Pivots. However the script is not recognizing the call function and nothing is being plot

        //alternate vClose1 if one wants to use the daily bar Close. NOTE that this will not work with Tick Replay
        vClose1 = call("/OHLC/getPrevOHLC.efs", "Close");

        Comment


        • #5
          muecke,

          Here is my take on your request. You will have to determine if it is what you are asking for. The code is commented.
          NOTE: You may also find useful monthly pivots in the eSignal ".../Formulas/Pivots" folder.
          PHP Code:
           //http://forum.esignal.com/showthread.php?21693-Dynamic-Monthly-Pivot-Points
          var fpArray = new Array();//added
          function preMain() {

              
          setPriceStudy(true);
              
          setStudyTitle("Dynamic Pivots Monthly");
              
          setIntervalsBackfill(true);//added
              
          setCursorLabelName("R2"0);
              
          setCursorLabelName("R1"1);
              
          setCursorLabelName("PP"2);
              
          setCursorLabelName("S1"3);
              
          setCursorLabelName("S2"4);
              
          setDefaultBarFgColor(Color.red0);//changed colors so I could see them on chart
              
          setDefaultBarFgColor(Color.brown1);
              
          setDefaultBarFgColor(Color.lime2);
              
          setDefaultBarFgColor(Color.cyan3);
              
          setDefaultBarFgColor(Color.magenta4);
              
          setDefaultBarThickness(20);
              
          setDefaultBarThickness(21);
              
          setDefaultBarThickness(22);
              
          setDefaultBarThickness(23);
              
          setDefaultBarThickness(24);
              
          setPlotType(PLOTTYPE_FLATLINES0);//changed to flat lines so I could see them on chart
              
          setPlotType(PLOTTYPE_FLATLINES1);
              
          setPlotType(PLOTTYPE_FLATLINES2);
              
          setPlotType(PLOTTYPE_FLATLINES3);
              
          setPlotType(PLOTTYPE_FLATLINES4);
              var 
          x=0;
              
          fpArray[x] = new FunctionParameter("NoOfMonthsBack"FunctionParameter.NUMBER);//added
              
          with(fpArray[x++]){
                  
          setName("# of Months Back Starting With 0");
                  
          setLowerLimit(0);        
                  
          setDefault(2);//series are arrays so ".getValue(-2)" is the 3rd month back if you count bar 0 as month 1
              
          }


          }

          //var vOpen = null;//not used in the script
          //var vOpen1 = null;//not used in the script
          //var vHigh = null;//not needed in the script
          var vHigh1 null;
          //var vLow = null;//not needed in the script
          var vLow1 null;
          var 
          vClose1 null;

          var 
          vPP null;
          var 
          vR1 null;
          var 
          vR2 null;
          var 
          vS1 null;
          var 
          vS2 null;

          var 
          bInit false//added
          var vH_Data null,vL_Data null,vC_Data null//changed to global
          function main(NoOfMonthsBack) {//added parameter
              
          var vHigh1=nullvLow1=nullvClose1=null;
              var 
          vTime getValue("time"); //create date object using bar time
              
          if (!bInit) {//added bInit routine to run series code only once
                  //vData = callFunction("/OHLC/getPrevMonthsOHLC.efs", "Open", "High", "Low", "Close", -2, 2);//"getPrevMonthsOHLC.efs" only has one parameter for Source not 3 
                  
          vH_Data high(inv("M")); //added
                  
          vL_Data low(inv("M")); //added
                  
          vC_Data close(inv("M")); //added
                  //above 3 variables will return a series of H, L, & C 
                  
          bInit=true;
              }
              if (
          vH_Data == null || vL_Data == null || vC_Data == null) return;//null check
              
          vHigh1=vH_Data.getValue(-NoOfMonthsBack);//monthly high of 3 months ago
              
          vLow1=vL_Data.getValue(-NoOfMonthsBack);//monthly low of 3 months ago
              
          vClose1=vC_Data.getValue(-NoOfMonthsBack);//monthly close of 3 months ago
              //NOTE: 
              //if(isLastBarOnChart()) debugPrintln("61: "+vHigh1+"\t"+vLow1+"\t"+vClose1);//for debug only
              //return vData;//return stops further execution of the script, is used only once to plot series and is placed at the end except for conditionals that stop execution

          /*//commented out this block since it isn't needed
              if (close(-1) == null) return;

              if (getBarState() == BARSTATE_NEWBAR && getMonth() != getMonth(-1)) {
                  vHigh1 = vHigh;
                  vLow1 = vLow;
                  //vClose1 = call("/OHLC/getPrevMonthsOHLC.efs", "Close"); //comment out this line if using alternate vClose1 
                  vHigh = high();
                  vLow = low();
              }

              if (vHigh == null)
                  vHigh = high();
              if (vLow == null)
                  vLow = low();


              vHigh = Math.max(high(), vHigh);
              vLow = Math.min(low(), vLow);


              //alternate vClose1 if one wants to use the daily bar Close. NOTE that this will not work with Tick Replay
              //vClose1 = call("/OHLC/getPrevOHLC.efs", "Close"); 

          */
              //for alternative Pivots that require today's Open use vOpen in the Pivot calculations


              
          vPP = (vHigh1 vLow1 vClose1) / 3;
              
          vR1 vPP vLow1;
              
          vR2 vPP vHigh1 vLow1;
              
          vS1 vPP vHigh1;
              
          vS2 vPP vHigh1 vLow1;


              
          //if (vOpen1 == null || vLow1 == null || vHigh1 == null || vClose1 == null) {//vOpen1 is not used in the scrip & redundant since a null check is already coded above
              //    return;
              //} else {
                  
          return new Array(vR2vR1vPPvS1vS2);
              
          //}

          Wayne
          Last edited by waynecd; 09-13-2014, 03:19 PM.

          Comment

          Working...
          X