Announcement

Collapse
No announcement yet.

New multi days High drawing as an horizontal line

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

  • New multi days High drawing as an horizontal line

    Hello, I would like to know if somebody can help me in creating an EFS formula that can draw me in a chart, and horizontal line indicating the High of the last 5 previous days, for example. I created the formula for a watchlist, so i add a column that gives me the high of the last 5 days in it. But i would like to add it to a chart as an horizontal line.
    Thanks!

  • #2
    it s fine, i solved it:


    function preMain() {
    setPriceStudy(true);
    setStudyTitle("5days High (5dH)");
    setCursorLabelName("5Max");

    setDefaultBarStyle(PS_SOLID);
    setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
    setDefaultBarThickness(2);
    setPlotType(PLOTTYPE_FLATLINES);
    }

    var bInit = false;
    var xClose = null;

    function main() {

    //var tdayHigh=high(0);
    var yestHigh=high(-1, inv("D"));
    var tdayMinusTwo=high(-2, inv("D"));
    var tdayMinusThree=high(-3, inv("D"));
    var tdayMinusFour=high(-4, inv("D"));
    var tdayMinusFive=high(-5, inv("D"));



    var rangeHighMath=Math.max(yestHigh, tdayMinusTwo, tdayMinusThree, tdayMinusFour, tdayMinusFive)+0.01;
    vClose=rangeHighMath;


    return (vClose);
    }

    Comment


    • #3
      tan60
      FWIW you could condense your script to the following by using the highest() function
      PHP Code:
      function preMain() {
          
      setPriceStudy(true);
          
      setStudyTitle("5days High (5dH)");
          
      setCursorLabelName("5Max");

          
      setDefaultBarStyle(PS_SOLID);
          
      setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
          
      setDefaultBarThickness(2);
          
      setPlotType(PLOTTYPE_FLATLINES);
      }

      function 
      main() {
          return 
      highest(5,high(inv("D")),-1);


      For the description and syntax of the highest() function (together with examples of its use) see this article in the EFS KnowledgeBase
      Alex




      Originally posted by tan60
      it s fine, i solved it:


      function preMain() {
      setPriceStudy(true);
      setStudyTitle("5days High (5dH)");
      setCursorLabelName("5Max");

      setDefaultBarStyle(PS_SOLID);
      setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
      setDefaultBarThickness(2);
      setPlotType(PLOTTYPE_FLATLINES);
      }

      var bInit = false;
      var xClose = null;

      function main() {

      var yesterdayHigh=high(-1, inv("D"));
      var tdayMinusTwo=high(-2, inv("D"));
      var tdayMinusThree=high(-3, inv("D"));
      var tdayMinusFour=high(-4, inv("D"));
      var tdayMinusFive=high(-5, inv("D"));



      var rangeHighMath=Math.max(yesterdayHigh, tdayMinusTwo, tdayMinusThree, tdayMinusFour, tdayMinusFive);
      vClose=rangeHighMath;


      return (vClose);
      }

      Comment


      • #4
        Nice tip, thanks!

        Comment


        • #5
          tan60
          You are welcome
          Alex


          Originally posted by tan60 View Post
          Nice tip, thanks!

          Comment

          Working...
          X