Announcement

Collapse
No announcement yet.

efs formula: pivots

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • efs formula: pivots

    I am new here:
    how do I get the system to show the pivots for the coming day

    b e f o r e the market opening?

    thank you!

    etmal

  • #2
    etmal
    It depends on how the efs is written. Most efs(s) I have seen require a change of day/date to compute the pivots in which case I don't think you can plot them before the market opens.
    You would need to write an efs that computes the pivots based on current data and then uses drawLineXxx() to draw them since an efs does not plot where there is no data.
    Alex

    Comment


    • #3
      pivots before the open

      Alex,
      Any chance you could post a more concrete example of what you mean for us lesser fools. Where would I put the draw line xxx line in the programming? Thanks...

      Comment


      • #4
        JIMMYZ
        Enclosed below is a simple example of how to retrieve today's HLC values and use those to compute and plot tomorrow's Pivot Point.
        Hope this helps
        Alex

        PHP Code:
        function preMain(){

            
        setPriceStudy(true);
            
        setStudyTitle("Forward Pivot");
            
        setShowCursorLabel(false);
        }

        function 
        main(){

            var 
        vSymbol getSymbol();
            
        vSymbol vSymbol+",D";

            var 
        vClose close(0,vSymbol);
            var 
        vHigh  high(0,vSymbol);
            var 
        vLow   low(0,vSymbol);
            
            var 
        vPivot = (vClose+vHigh+vLow)/3;
            
            if(
        getBarState()==BARSTATE_NEWBAR){
                
        drawLineRelative(1vPivot20vPivotPS_SOLID2Color.magenta"Pivot");
                
        drawTextRelative(21vPivotformatPriceNumber(vPivot), Color.magentanullText.BOLD|Text.VCENTER"Arial"11"text");
            }
            
            return;

        Comment


        • #5
          Thanks Alex,

          I appreciate the effort. Could I just add the last two lines of other pivot codes to just make that data move to the next day? It helps to see these in place when the market opens.

          Comment


          • #6
            JIMMYZ
            Not sure I quite understand what you are asking.
            Alex

            Comment


            • #7
              Sorry let me be more specific. I use other pivot formulas and I wondering if I add the last two lines of code from the example you gave me, would that just post the data for the next day? drawLineRelative, drawTextRelative. I tried it but it did not put in the data. Thanks again

              Comment


              • #8
                JIMMYZ
                I imagine you are referring to drawLineRelative() and drawTextRelative(). In that case no they will not. Those are just the instructions to plot a line and to write some text. The values used by those instructions are calculated in the lines above ie.
                var vSymbol = getSymbol();
                vSymbol = vSymbol+",D";

                var vClose = close(0,vSymbol);
                var vHigh = high(0,vSymbol);
                var vLow = low(0,vSymbol);

                var vPivot = (vClose+vHigh+vLow)/3;

                However without knowing to which efs you would be transferring these lines of code I can't suggest copying them over. This is because the names I used as variables (ie vClose, vHigh, etc) are commonly used and there could be some conflict. If you do copy them over make sure they are not already being used in the other efs.
                Alex

                Comment


                • #9
                  Thanks Alex....I will try to correct the issues and see if my problem can be easily solved. I appreciate the fast replies.

                  Comment


                  • #10
                    Alex,
                    It seems that the code that I used based on the one posted below recalculates the pivots based on todays trading after the stock opens. Before the open its based on yesterdays numbers. How do I get the formula to just keep yesterdays numbers and not change the results based on todays trading?

                    Comment


                    • #11
                      JIMMYZ
                      The sample script I posted earlier always uses the most recent daily bar to calculate the pivots so as soon as the market opens and today's daily bar is created it uses that bar to compute the pivot
                      The simplest solution I can think of is to check if the system time is within user defined times If it is then the efs uses yesterday's daily bar to compute the pivot, if not it uses today's daily bar. These user defined times are set in line 17 of the enclosed efs in the following condition
                      if(hhmm >= 930 && hhmm < 1559)
                      In the first image below I set those times to include the current time and the efs plots the pivot using yesterday's bar. In the second image I instead set the times so as not to include the current time and the efs uses today's bar to calculate the pivot.
                      The option of using the system time allows you to plot charts that include pre or post market activity without affecting how the pivot is calculated
                      Alex





                      Note that in the images the Pivot Point.efs is used for comparison


                      PHP Code:
                      function preMain(){

                          
                      setPriceStudy(true);
                          
                      setStudyTitle("Forward Pivot");
                          
                      setShowCursorLabel(false);
                      }

                      function 
                      main(){

                          var 
                      today = new Date();
                          var 
                      hhmm = (today.getHours()*100)+today.getMinutes();

                          var 
                      vSymbol getSymbol();
                          
                      vSymbol vSymbol+",D";
                          
                          if(
                      hhmm >= 930 && hhmm 1559){
                              var 
                      vClose close(-1,vSymbol);
                              var 
                      vHigh  high(-1,vSymbol);
                              var 
                      vLow   low(-1,vSymbol);
                          }else{
                              var 
                      vClose close(0,vSymbol);
                              var 
                      vHigh  high(0,vSymbol);
                              var 
                      vLow   low(0,vSymbol);
                          }
                          
                          var 
                      vPivot = (vClose+vHigh+vLow)/3;
                          
                          
                      drawLineRelative(1vPivot20vPivotPS_SOLID2Color.magenta"Pivot");
                          
                      drawTextRelative(21vPivotformatPriceNumber(vPivot), Color.magentanullText.BOLD|Text.VCENTER"Arial"11"text");
                          
                          
                          return;

                      Comment


                      • #12
                        Thanks for all your help Alex.

                        Comment

                        Working...
                        X