Announcement

Collapse
No announcement yet.

Open Value from user specified bar

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

  • Open Value from user specified bar

    I am searching for the efs.formula to plot a Flatline in the chart at the open-value of a bar that may be specified by my own.

    For example I would like to plot the open-value from the 9:30 bar in my S&P-Globex Charts.

    Thanks for guiding me.

  • #2
    helmutw
    The enclosed efs will plot a flatline from a user specified time (default is 930).
    Alex

    PHP Code:
    function preMain() {

        
    setPriceStudy(true);
        
    setStudyTitle("Open @ Time");
        
    setPlotType(PLOTTYPE_FLATLINES);
        
    setCursorLabelName("Open");
        
        var 
    fp1 = new FunctionParameter("Time"FunctionParameter.NUMBER);
        
    fp1.setName("Time");
        
    fp1.setDefault(930);
    }

    var 
    vO null;

    function 
    main(Time) {

        if((
    getHour()*100)+getMinute()==Time){
        
    vOopen(0)
        }

        return 
    vO;

    Comment


    • #3
      @ Alexis C. Montenegro

      Thanks for your help.

      I tried to calculate an indicator with this open value: Open is the zero line. Calculating the difference from the actual bars high and low as shown in the chart.

      But the value of the first bar refers to the open value from yesterday.

      Can you please solve this problem?

      Thank You.

      Helmut

      function preMain() {
      setPriceStudy(false);
      setStudyTitle("High Low - TOpen");
      setCursorLabelName("High Low - TO",0);
      setDefaultBarThickness(2,0);
      setDefaultBarThickness(2,1);
      setDefaultBarThickness(3,2);
      setDefaultBarFgColor(Color.blue, 0);
      setDefaultBarFgColor(Color.red, 1);
      setDefaultBarFgColor(Color.black, 2);
      setPlotType(PLOTTYPE_HISTOGRAM, 0);
      setPlotType(PLOTTYPE_HISTOGRAM, 1);
      setPlotType(PLOTTYPE_LINE, 2);

      var fp1 = new FunctionParameter("Time", FunctionParameter.NUMBER);
      fp1.setName("Open @ Time");
      fp1.setLowerLimit(1);
      fp1.setDefault(1530);
      }

      var vO = null;

      function main(Time) {
      var Null = 0;
      var Hplus = 0
      var Lminus = 0
      var HMO = (high()- vO);
      var LMO = (low()- vO);

      if((getHour()*100)+getMinute()==Time){vO= open(0)}

      if (HMO >0) {Hplus = HMO} else if (HMO<=0) {Hplus=0};
      if (LMO <0) {Lminus = LMO} else if (LMO>=0) {Lminus=0};

      return new Array (Hplus, Lminus, Null);

      }
      Attached Files

      Comment


      • #4
        Helmut
        I believe that some time ago I had already posted an efs that does something similar. If I can find it I will post the link here else I can modify the one you posted.
        Alex

        Comment


        • #5
          Helmut
          You can use the efs in this post as a blueprint to create yours.
          Alex

          Comment


          • #6
            hmm,

            please have a look at my chart. The open-diff.efs doesn´t show the expected result.
            Attached Files

            Comment


            • #7
              Helmut
              In the open-diff.efs I omitted to add the user defined variable in the condition so if you set the time using Edit Studies it will not have any effect on the efs (NB I have now replaced the efs with the revised version).
              If you have not already corrected this open the efs and replace
              if((getHour()*100)+getMinute()==930){
              with
              if((getHour()*100)+getMinute()==Time){
              The enclosed screenshot shows the plot as it appears at my end
              Alex

              Comment


              • #8
                Helmut

                But the value of the first bar refers to the open value from yesterday.

                That is because in your efs HMO and LMO are computed before the current vO (which is a Global variable) so they use its prior value which on the first bar of the day is yesterday's vO. Move these two lines
                var HMO = (high()- vO);
                var LMO = (low()- vO);

                to a line after
                if((getHour()*100)+getMinute()==Time){vO= open(0)}
                and it should take care of the problem.
                In the enclosed images you can see the results before and after moving those lines in the script
                Alex



                Comment


                • #9
                  Alexis,

                  thanks for your help!

                  Comment

                  Working...
                  X