Announcement

Collapse
No announcement yet.

High - low

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

  • High - low

    Hi Alexis:

    I need a simple indicator and if I get another "syntax error" I'm going to put my
    fist thru the drywall.

    I would like the (high - low) / 0.25 and plotted as a histogam.

    Could you help?

    TIA,

    dom

  • #2
    dom
    The script enclosed below should do it
    Alex

    PHP Code:
    function preMain(){
        
    setPriceStudy(false);
        
    setStudyTitle("example");
        
    setPlotType(PLOTTYPE_HISTOGRAM);
    }

    function 
    main(){

        return (
    high(0) - low(0)) / 0.25;

    Comment


    • #3
      Yes!! That's it! Excellent.

      If Could I impose upon you just a little more. I just thought of this. Could you have the histogram bars turn green if the result is equal to or greater than 12 and red if not?

      Thanks a million Alexis.

      dom


      Originally posted by Alexis C. Montenegro
      dom
      The script enclosed below should do it
      Alex

      PHP Code:
      function preMain(){
          
      setPriceStudy(false);
          
      setStudyTitle("example");
          
      setPlotType(PLOTTYPE_HISTOGRAM);
      }

      function 
      main(){

          return (
      high(0) - low(0)) / 0.25;

      Comment


      • #4
        dom
        Modify the efs in the following way. Instead of using the expression (high(0)-low(0))/0.25 directly in the return statement create it as a variable inside main ie

        var vDiff = (high(0)-low(0))/0.25;

        Then use vDiff for your condition ie

        if(vDiff >= your number)
        insert here the command to be executed


        At this point in your return statement replace the original expression with vDiff
        Give it a try and if you have a problem post what you have done
        Alex

        Comment


        • #5
          This didn't work:

          function preMain(){

          setPriceStudy(false);

          setStudyTitle("Andy's eminibar");

          setPlotType(PLOTTYPE_HISTOGRAM);

          }



          function main(){

          var vDiff = (high(0)-low(0))/0.25;

          if(vdiff >= 12) {
          setplottype(plottype_histogram, color.green);

          }

          if(vdiff < 12) {

          setplottype(plottype_histogram, color.red);

          }


          I tried to find what's the format for "if"
          and knowledgebase or glossary didn't have it. It sure would be nice if I could just type "if(" or what ever I type and it shows the required format needed.

          I even typed "colors" and get a bunch of
          of other things. I sure wish Esignal was as easy as Amibroker.

          dom

          Comment


          • #6
            dom
            The command you need is setBarFgColor() and would be used as follows.

            if(vDiff>=12){
            setBarFgColor(Color.green);
            }else{
            setBarFgColor(Color.red);
            }


            For a complete list of all the functions see the EFS Function Reference and the EFS2 Function Reference in the EFS KnowledgeBase. In the KB you may also want to go through the Help Guides and in particular the Guide to Developing eSignal Indicators
            Alex

            Comment


            • #7
              Hi Alexis:

              I've got no syntax errors with this:

              function preMain(){

              setPriceStudy(false);

              setStudyTitle("Andy's Emini");

              setPlotType(PLOTTYPE_HISTOGRAM);

              }



              function main(){

              var vDiff = (high(0)-low(0))/0.25;

              if(vDiff >= 12) {
              setBarFgColor(Color.green);
              } else {
              setBarFgColor(Color.red);
              }

              }


              The only problem is no histogram is plotted. Although the cursor window is changing colors. Shouldn't the plottype
              histogram above plotted the bars?

              dom

              Comment


              • #8
                dom
                You forgot to include the return statement in your script. As I suggested in an earlier reply you would return vDiff in place of the original expression
                Alex

                Comment


                • #9
                  That did it!

                  I cancelled my order for the drugs and alchohol.

                  Thanks for your patience.

                  dom

                  Comment


                  • #10
                    dom
                    You are most welcome
                    Alex

                    Comment

                    Working...
                    X